http
http copied to clipboard
I tried to connect with localhost 8081 port but its connect with diffrent port
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());
}
Any update to this issue?
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