gpt4 book ai didi

WebSocketException : Connection to was not upgraded to websocket 上的 Flutter Socket io 错误

转载 作者:行者123 更新时间:2023-12-03 17:23:34 52 4
gpt4 key购买 nike

我用 this包,它在测试网站上正常工作,但在应用程序中我收到了这个错误

WebSocketException: Connection to 'https://socket.excopro.com:0/socket.io/?EIO=3&transport=websocket#' was not upgraded to websocket
这是我的代码
SocketService() {
var socket = io(
'https://socket.excopro.com:443/', <String, dynamic>{
'transports': ['websocket'],
'autoConnect': true,
});
socket.on('connect', (_) {
print('connect');
socket.emit('msg', 'test');
});
socket.on("connecting", (data) => print('connecting'));
socket.on('connect_error', (data) {
print(data);
socket.emit('msg', 'test');
});
}

最佳答案

我遇到了同样的问题。
就我而言,我使用 Nginx 作为代理。我通过在 Nginx 配置中添加一些代理 header 来解决这个问题。

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
你可以引用这个 link .

关于WebSocketException : Connection to was not upgraded to websocket 上的 Flutter Socket io 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64125735/

52 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com