简体   繁体   English

netty-socketio:客户端未完成升级-关闭传输

[英]netty-socketio: client did not complete upgrade - closing transport

I have a socket server running with netty-socketio and a web app that connects to it using socket.io-client JS library. 我有一个运行netty-socketio的套接字服务器和一个使用socket.io-client JS库连接到它的Web应用程序。

The problem is that I'm losing a few connections (not all, let's say 20%). 问题是我失去了一些连接(不是全部,比如说20%)。

For the lost connections: right after the connection is made by the client, the server logs client did not complete upgrade - closing transport and disconnects the client. 对于丢失的连接:客户端建立连接后,服务器立即记录client did not complete upgrade - closing transport并断开客户端连接。

This happens on my production server (using nginx as proxy) and also on my local environment (connecting directly to the netty-socketio server). 这发生在我的生产服务器(使用nginx作为代理)以及我的本地环境(直接连接到netty-socketio服务器)上。 It's pretty much random and I cant identify a pattern on it. 这几乎是随机的,我无法确定其上的图案。 For example, if I continuously keep refreshing the client app on the browser (with a 5 seconds interval), at some point this error will happen, and for the subsequent tries it will work normal again (until it happens another time). 例如,如果我持续不断地刷新浏览器上的客户端应用程序(间隔为5秒),则有时会发生此错误,并且在随后的尝试中它将再次正常运行(直到再次发生)。

This is the error on the netty-socketio lib: https://github.com/mrniko/netty-socketio/blob/master/src/main/java/com/corundumstudio/socketio/transport/WebSocketTransport.java#L196 but I could not figure out why it happens randomly (some times at the first try) 这是netty-socketio库上的错误: https : //github.com/mrniko/netty-socketio/blob/master/src/main/java/com/corundumstudio/socketio/transport/WebSocketTransport.java#L196但我无法弄清楚为什么它是随机发生的(第一次尝试有时会发生)

Any thoughts on this are really appreciated. 任何对此的想法都非常感激。

Thanks 谢谢

After some research and tests I found out that when using netty-socketio as server, you need to specify the transport method on the client side. 经过一些研究和测试,我发现使用netty-socketio作为服务器时,需要在客户端指定传输方法。

var socket = io('server-address', { transports: [ 'polling' ] });
// or
var socket = io('server-address', { transports: [ 'websocket' ] });

If you don't specify it, the connection will be established using polling as transport method and netty will automatically try to upgrade it to websocket. 如果未指定,则将使用轮询作为传输方法来建立连接,netty将自动尝试将其升级到websocket。 This is what was causing connection failures. 这是导致连接失败的原因。

After specifying the transport method I had 0% connection failures so far. 指定传输方式后,到目前为止,我的连接失败率为0%。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM