Domanda

We are using the vert.x sockJS implementation for our websockets solution. When the vert.x sends a few messages quickly after each other some messages will arrive very late on the client. The late messages only arrive when the heartbeat has been sent. Any idea how this is possible?

We temporarily fixed this by putting our sockjssocket.write() method inside a synchronized block, but this feels a bit like a hack. The reason we put this in synchronized block is because we think it has something to do with parallel writing to the socket buffer.

kind regards,

Daan

È stato utile?

Soluzione

WebSockets is protocol layer implemented on top of TCP.

TCP has some mechanics to optimise network performance, and allow reliable and ordered deliver of stream chunks. One of those "optimisations" is Nagle's algorithm, it queues small chunks in network layer, before they satisfy size of packet to send, and sends only once it is big enough.

What potentially is happening that this algorithm is not disabled in vert.x. Looks like this points to actual setting that you can use in order to disable it.

If this wont help, you need to make sure that SockJS library does not "recreate" same mechanics for "optimisation" purposes.

The purpose of this algorithm is to combine smaller chunks and send as one packet reducing underlying network overhead carrying TCP header for each chunk. If you send lots of small ones, please make sure you optimise it (merge yourself) as it is better to send in bigger chunks.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top