6

I'm using Vert.x and SockJS to transfer data encapsulated in messages. Is there a specification how big the SockJS/Websocket messages can be?

phil
  • 1,377
  • 2
  • 9
  • 14

1 Answers1

7

There isn't an explicit limit of a size of a SockJS message. But unfortunately SockJS is quite fragile and should not be used to send huge data. In ideal world you'd send control messages (latency-sensitive) over SockJS and big payloads (for throughput) using external methods - for example using an AJAX call.

On technical side you should be able to push pretty much anything over websockets transport, but on streaming and polling ones you need to be more careful. Specifically, a polling requests must be reestablished within 5 seconds, and it may be tough when all the bandwidth is occupied by sending data from the browser to the server. So, uploading large blobs is not recommended with sockjs.

Marek
  • 3,471
  • 1
  • 16
  • 15
  • 2
    Thanks! I did some more investigation and found out, that the default web socket frame size limit of Netty (which is used in Vert.x) is set to something about 100k. This totally fits at the moment (messages are about 5k), but when the messages start to grow beyond 100k, I'll consider the sockjs/ajax solution. – phil Nov 28 '12 at 13:51
  • I am using spring sockjs implementation, do not find a way to specify the maximum limit. Does sockjs client restrict message size in any way or does it provide a way specify max size? – cpandey05 Feb 12 '14 at 12:49