[erlang-questions] Help Using Bullet + BERT

Steve Davis steven.charles.davis@REDACTED
Tue Jul 2 00:54:07 CEST 2013


Not sure, but you may be looking for this js snippet:
ws = new WebSocket(ws_url, ws_protocol);
ws.binaryType = "arraybuffer";


On Monday, July 1, 2013 2:03:18 AM UTC-5, Kolo Rahl wrote:
> I've been messing around with Bullet and Cowboy recently and am loving how 
> easy it is to perform websocket handling. But then I tried integrating a 
> BERT JavaScript library with it (the one from 5HT/n2o) and noticed that the 
> messages hitting my server are in a form that can't be parsed by 
> binary_to_term/1, which is the whole point to to using BERT encoding. Even 
> just sending a string or an integer results in an error on the server.
> Client/JavaScript:
> bullet.send(Bert.encode("testing"))
> Server/Erlang:
> ** Cowboy handler bullet_handler terminating in websocket_handle/3
>    for the reason error:badarg
> ** Message was {text,<<194,131,107,0,7,116,101,115,116,105,110,103>>}
> [...]
> ** Stacktrace: [{erlang,binary_to_term, 
> [<<194,131,107,0,7,116,101,115,116,105,110,103>>],[]},
> [...]
> Calling term_to_binary/1 using "testing" returns 
> <<131,107,0,7,116,101,115,116,105,110,103>>, so I can only imagine it's 
> that "194" part at the head of the binary object that's the problem, but I 
> don't know why it's there and whether that's a result of the internals of 
> the client or of the server. Any help?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130701/3efe9b7c/attachment.htm>

More information about the erlang-questions mailing list