Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS Error: Address already in use, errno = 48 #100

Open
harshitwe360 opened this issue Sep 15, 2023 · 1 comment
Open

OS Error: Address already in use, errno = 48 #100

harshitwe360 opened this issue Sep 15, 2023 · 1 comment

Comments

@harshitwe360
Copy link

I'm using opened_client for keycloak authentication and its working fine in android devices but when I run in IOS simulator it will throw error

  Unhandled Exception: SocketException: Failed to create server socket (OS Error: Address already in use, errno = 48), address = 0.0.0.0, port = 8765
  #0      _NativeSocket.bind (dart:io-patch/socket_patch.dart:1030:7)
  <asynchronous suspension>
  #1      Authenticator.authorize (package:openid_client/openid_client_io.dart:87:5)

// and the code I used

Future<bool> keyClockAuth() async  {

   String urlStr = domain.apiKeycloakRealm!=null
        ? "${domain.apiKeycloakUrl}/realms/${domain.apiKeycloakRealm}/"
        : AppConstants.keycloakUrl;
    Uri uri = Uri.parse(urlStr);

    // create the client
    var issuer = await Issuer.discover(uri);
    var client = Client(issuer, clientId);

    // create a function to open a browser with an url
    urlLauncher(String url) async {
      if (await canLaunchUrlString(url)) {
        await launchUrlString(url);
      } else {
        throw 'Could not launch $url';
      }
    }

    // create an authenticator
    var authenticator = Authenticator(client, port: 8765,
        urlLancher: urlLauncher);

    // starts the authentication
    var c = await authenticator.authorize();

    // close the webview when finished
    closeInAppWebView();

}

Thankyou

@rbellens
Copy link
Contributor

did you try using another port?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants