flutter web中如何连接wss?
我尝试使用 flutter 连接套接字 io。之前,我们的服务器端开发人员给了我一个没有 SSL 证书的 URL,一切正常。但现在,我们的服务器有 SSL 证书,我无法连接到该套接字 io。这是我的连接代码:
Socket socket = io(
'wss://server-address',
OptionBuilder()
.setTransports(['websocket'])
.disableAutoConnect()
.build());
socket.connect();
socket.onConnect((_) {
print('socket connect');
});
socket.onConnectError((data) => print('socket error = ' + data.toString()));
我收到此错误:
socket error = {msg: websocket error, desc: null, type: TransportError}
我尝试将我的 Web 应用程序部署在 Firebase 等安全主机上,但仍然遇到问题。在检查 Firefox 时,我也看到这个错误:
Firefox cant establish a connection to the server
如何解决这个问题?如何在flutter web中连接到安全的socket-io地址?
I try to connect a socket-io with flutter. Before, our server-side developer give me an URL without SSL-Certificate and everything is worked. But now, our server has SSL-Certificate, I can't connect to that socket-io. This is my code to connect:
Socket socket = io(
'wss://server-address',
OptionBuilder()
.setTransports(['websocket'])
.disableAutoConnect()
.build());
socket.connect();
socket.onConnect((_) {
print('socket connect');
});
socket.onConnectError((data) => print('socket error = ' + data.toString()));
I get this error:
socket error = {msg: websocket error, desc: null, type: TransportError}
I try to deploy my web application on a secure host like firebase but still have problems. In inspect of firefox, I also see this error:
Firefox cant establish a connection to the server
How to fix this problem? How to connect to secure socket-io address in flutter web?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论