Closed TheChifer closed 7 years ago
Please can you upload a sample project that reproduces the bug you have found, so that I can track it down.
http://localhost:9000/ Hit enter on the input 100 4k data('a's) are returned via ws with a sequence number Eg :1 -- [data] 2 -- [data] etc
Checkout large frames with multiple data, you could see the loss very easily
Let me know if you want more info, its quite a bad loss causing issues in prod
If I use streams, I don't see intermittent losses. but there is a max message cap of 271 what ever the size of the message, subsequent messages beyond 271 is lost.
Thank you, I checked it and it works as intended. When using actor based api or LegacySockJS (as in your case) you can't control backpressure, so if the underlying buffer fills up, the new elements are automatically discarded (and that is why you are seeing message loss).
However you can control the buffer size by specifying it in the settings:
@Override
public SockJSSettings settings() {
return new SockJSSettings()
.withWebsocket(true)
.withSessionBufferSize(512*1024) // by default is 64k
.withStreamingQuota(4096);
}
By using those settings in your sample app you will not see any loss (probably you need to tune it according to your use case).
Up to play2-sockjs 0.4.x, the underlying implementation was not stream based and the buffer was unbounded (so that's why you were not seeing any message loss), but that's bad because you don't have any control over memory usage.
Thanks, I did play with both session and send buffer, however did have issues even with 512k. I will check again.
When dimensioning the session buffer you have to consider the rate at which you emit data and the client consumes it, that's why the value depends on the use case.
After upgrading to Play2.5.x & play2-sockjs 0.5.0/0.5.1 I am seeing message losses. SockJS setup
With v2.5. upgrade I can see sockjs is buffering multiple messages emitted by the linked Actor, hence I see larger array frames sent to the client Eg an 'a' frame with 8 array elements with the size of 21846
these large wrapped frames misses messages, for example about 3 messages in the middle are missing, it should be a frame having 11 message elements. Not all wrapping frames misses messages but happens often enough.
From server logs I can see the actor is firing messages correctly to the sockjs router actor & from browser network tab can see the loss.
SockJS client is white listed only to use websocket transport
with v2.4 I see smaller frames of 4k with a single message frames. 2.4 is NO loss and very stable.