I'm developing a websockter server using node.js and I've discovered some quirks in Chrome. Chrome on (OS X 10.7 64 bit) the max string length is 17740, whereas Firefox seems to handle the very large string with no problem. Another problem I found is that the max message length that can be sent in websocket hybi-17 is 2^64-1, or max int in an unsigned 64 bit integer, but javascript can't even handle numbers that large in its number format. It seems odd to have your protocol use numbers that your front end language can't handle easily. So the real question here is there a way I can force the websocket interface in the browser to restrict messages to a certain length. I can easily do it with my own functions, but I know its bad to really trust any client side code. I'm looking for the best way to get some consistency across all platforms.
解决方案
Restrict it on the server, if the incoming data is too long, just close the connection.