Just a quick addition to my series of posts on the websocket in haxe series (Part 1, Part 2) …
A significant issue with haxe remoting is that the allowed message size is constrained. This means that when passing parameters that exceed 4kb or so, you’ll get a nasty “message too big” error.
Based on code written by Anthony Loizeau(see this post), my haxe websocket library now supports arbitrarily large messages. It does this by splitting up the haxe serialisation string into pieces, sending them piece by piece through the socket, and then stitching them together on the other end.
The new example unsizedremoting in the code illustrates how to use the new functionality. The client in the example repeatedly calls a server function sendData(s:String) with a string that keeps doubling in size. It gets to around 50kb in size before a noticable message decoding lag occurs (on my eeepc).
You can browse the code, download a zip, or clone it directly:
hg clone http://hg.bp.io/public/websockets websockets
The code is not well tested, but seems to work okay. If you encounter any issues, let me know, and we can make this a nice stable implementation. :)
I must say also, that the latest websockets draft supports multi-part messages. I am not using this functionality in the library, but will probably incorporate it at some time in the future. Right now, the haxe remoting logic uses its own multi-part message handling.
3 replies on “Haxe Websockets Remoting with Large Messages”
Can you please add a flash/neko/nme/hxcpp websocket client, the current version has a js proxy client from my understanding, it would be useful to have a websocket client in flash/neko/nme/hxcpp.
Hi iongion, thanks!
If you want to connect from flash to a server, then the flash remoting functionality available in the haxe library (e.g., http://haxe.org/doc/flash/chat) should be more than fine. To use this with large messages, you can directly use Anthony Loizeau’s code.
If you are using flash, I would strongly advise against using websockets for now, as the draft is still in spec and due to a recent security flaw, websockets have been disabled by default in some browsers (http://hacks.mozilla.org/2010/12/websockets-disabled-in-firefox-4/).
I appreciate that in the haxe spirit, my code should support all the standard haxe targets, but unfortunately I don’t have to time to implement and test all of them.
Another useful link, if you want to connect to a websocket server from flash: https://github.com/gimite/web-socket-js