简体   繁体   中英

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.

The problem is that I'm losing a few connections (not all, let's say 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.

This happens on my production server (using nginx as proxy) and also on my local environment (connecting directly to the netty-socketio server). 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).

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)

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.

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. This is what was causing connection failures.

After specifying the transport method I had 0% connection failures so far.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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