Ama*_*ngh 12 tcp socket.io dart iot flutter
我正在尝试将我的 android 应用程序连接到 Tcp iot 服务器,首先我使用 wifi 连接到 tcp 服务器,然后尝试套接字连接,但它显示连接超时的相同错误。
print(r);
}).catchError((e) {
print(e);
});
Run Code Online (Sandbox Code Playgroud)
wifi连接没有任何错误。
Socket.connect("192.168.5.10", 5800).then((socket) {
print('Connected to: '
'${socket.remoteAddress.address}:${socket.remotePort}');
socket.destroy();
});
Run Code Online (Sandbox Code Playgroud)
此处显示未处理的异常:SocketException: OS Error: Connection timed out, errno = 110, address = 192.168.5.10, port = 49590
小智 2
我在flutter中使用了http包。并得到了与你相同的错误。我的解决方案是“我使用 ngrok 公开我的本地主机”,然后我将 url 更改为 ngrok 转发的 url。-注意:使用ngrok仅测试api。当我们将其托管到服务器时,不会出现任何与响应时间相关的问题,因此您可以使用您的服务器 IP。
| 归档时间: |
|
| 查看次数: |
6395 次 |
| 最近记录: |