Sending large amount of data over web-socket
Added by Bogdan Cosescu about 13 years ago
Hello!
I built an WT app that pushes data to the browser. I'm trying to use the web-sockets but Chrome(18.0.1025.168) reports in the debug console that "WebSocket frame length too large: 2255708234449806 bytes".
The data that I'm sending is a black bmp image(256X256) with 24 bit color. This image has 192 kb. If I send a image 30x30 with 24 bit color web-socket works just fine.
Is there a problem on WT Web-Socket implementation?
If it helps I could provide a sample app.
Thanks.
Replies (7)
RE: Sending large amount of data over web-socket - Added by Ronald Peer about 13 years ago
I think you need to adapt the default setting in Wt_config.xml, e.g.:
<!-- Maximum HTTP request size (Kb)
Maximum size of an incoming POST request. This value must be
increased when the user is allowed to upload files.
-->
<max-request-size>1024</max-request-size>
Hope this helps.
Regards,
Ronald
RE: Sending large amount of data over web-socket - Added by Bogdan Cosescu about 13 years ago
Hi!
I tried this approach but it doesn't bring anything new. From my WT app I'm pushing data to the client. I've seen that if my data doesn't exceed 64kb the websocket is used for transmission every time. But if my data goes above 64kb the websocket is closed(Chrome gives me an error in console) and the fallback is used.
RE: Sending large amount of data over web-socket - Added by Ronald Peer about 13 years ago
I guess one of the Wt developers should look into this one then...
Regards, Ronald
RE: Sending large amount of data over web-socket - Added by Bogdan Cosescu about 13 years ago
I found the problem:
in WTReply.C on line 340:
original code is:
for (unsigned i = 0; i < 8; ++i)
nextCout_ += (char)(payloadLength >> ((7-i) * 8));
in this case payloadLength is of std::size_t which has 4 bytes not 8 bytes.
My fix:
for(unsigned i = 8; i > sizeof(payloadLength); ---i)
nextCout_ += (char)0x0;
for (unsigned i = 0; i < sizeof(payloadLength); ++i)
nextCout_ += (char)(payloadLength >> ((sizeof(payloadLength) - 1 - i) * 8));
RE: Sending large amount of data over web-socket - Added by Koen Deforche about 13 years ago
Hey,
Indeed you spotted the problem right on. We indeed were assuming that std::size_t is 64bit right now.
Thanks for the fix.
Regards,
koen
RE: Sending large amount of data over web-socket - Added by Bogdan Cosescu about 13 years ago
After fixing the issue...I run some test with my app.
There is visual decrease in performance between websocket and post replies. It seems that pushing large updates on web socket performs slower than Ajax.
Shouldn't be the other way around?
Any feedback on websocket usage is appreciated.
RE: Sending large amount of data over web-socket - Added by Koen Deforche about 13 years ago
Hey,
WebSockets currently do not support compression, which is a likely reason to see worse performance because of bandwidth limitations ?
WebSockets are mostly beneficial when you expect many small updates, and in case of server push.
Regards,
koen