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

I tried to connect with localhost 8081 port but its connect with diffrent port #336

Open
krButani opened this issue Mar 30, 2024 · 2 comments

Comments

@krButani
Copy link

I tried to connect with localhost 8081 port but its connect with diffrent port
Error show below

SocketException: Connection refused (OS Error: Connection refused, errno = 111), address = 127.0.0.1, port = 37702

code:

try {
      final wsUrl = Uri.parse('ws://127.0.0.1:8081/');
      final channel = WebSocketChannel.connect(wsUrl);

      await channel.ready;

      channel.stream.listen((message) {
        print(message);

        //channel.sink.close(status.goingAway);
      });
      channel.sink.add(
          '{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3RcL2lzaGFuYmhhaVwvaWJcL2RhXC8iLCJ0b2tlbiI6IiQyeSQxMCQ5QTAuU2xkWDlpQllzdXJ3QWc1MVwvT3ZyT0tcLzF2TDZkUFFFMER3aU5tSlNkdUFtM09ad1phIiwic2FtcGxlIjoiMiIsInRyaXAiOiI6OjEifQ.B-RqQ6gO-w1mWT3uVVAiObGKRaKKzH0LT5L4zDa_NoE"}');
    } catch (e) {
      print(e.toString());
    }
@felixkarnodev
Copy link

Any update to this issue?

@anusha928
Copy link

This is because the localhost 8031 is not accessible by your mobile device. so u have to do adb reverse .
the command is
abd reverse tcp:8031 tcp:8031

if u are using emulator or simulator than use the server 10.0.2.2

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

3 participants