websocket responses appear to be cut off

1

So my websocket server (socket.io) is sending JSON data to my clients who connect with their web browsers (e.g. Firefox).

It works fine when I am sending short responses.

However, when I send a large JSON response, the response is always 219265 characters long -- it cuts off!!!

Therefore, I am unable to parse the JSON data because it cuts off before the transmission is complete!

What can I do?

I tried to do it on Chrome too - it also cuts off after 219265 characters.

My webserver is running Apache2. The websocket server (socket.io) is listening on port 8002 of the server, and Apache re-directs any websocket requests to 8002. It has been working perfectly for short responses.

Eamorr

Posted 2014-10-01T13:40:34.887

Reputation: 227

If my math is correct you are trying to send 438,530 bytes which is a lot for a single transmission packet. – Ramhound – 2014-10-01T14:12:48.023

It's not that much, surely? – Eamorr – 2014-10-01T16:16:18.033

I'm guessing it's some Apache2 thing, but I can't find anything online... – Eamorr – 2014-10-01T16:22:02.737

Answers

0

I figured it out...

Not an Apache2 problem, not a socket.io problem...

It's to do with the nodejs child process having it's default stdout buffer length set to 200*1024 (204800).

http://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback

All I had to do was set 'maxBuffer' to a bigger number and everything was fine...

Phew!

Eamorr

Posted 2014-10-01T13:40:34.887

Reputation: 227