[erlang-questions] Help Using Bullet + BERT

Kolo Rahl kolorahl@REDACTED
Mon Jul 1 09:03:18 CEST 2013


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/73f4b2f2/attachment.htm>


More information about the erlang-questions mailing list