admin管理员组文章数量:1424567
Im trying to establish a websocket connection with an executable that starts it and the issue is flutter actually trying to connect to it. I want it to be connected to port 8765 and I've tried to make it clear and yet I get:
SocketException (SocketException: Connection refused (OS Error: Connection refused, errno = 111), address = 192.168.1.104, port =
49832 )
Why? it does this every time with a new 5 digit port?
Future<void> localhostCheck() async {
final port = 8765;
print(port);
final ip = await getLocalIP();
print(ip);
final uri = Uri.parse('ws://$ip:$port');
if (_channel != null) {
print("Closing existing WebSocket connection...");
_channel!.sink.close(); // Removed status.goingAway
_channel = null;
}
print("Trying to connect to WebSocket at $uri...");
final channel = WebSocketChannel.connect(uri);
await channel.ready;
print("Connected to WebSocket at $uri");
}
and I get:
I/flutter (25563): 192.168.1.104
I/flutter (25563): Trying to connect to WebSocket at ws://192.168.1.104:8765...
E/flutter (25563): [ERROR:flutter/runtime/dart_vm_initializer(40)] Unhandled Exception: WebSocketChannelException: SocketException: Connection refused (OS Error: Connection refused, errno = 111), address = 192.168.1.104, port = 49832
E/flutter (25563):
本文标签: pythonSocket Exceptionbut on a different portStack Overflow
版权声明:本文标题:python - Socket Exception, but on a different port? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744749315a2623077.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论