<div dir="ltr">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.<div>
<br></div><div>Client/JavaScript:</div><div><font face="courier new, monospace">bullet.send(Bert.encode("testing"))</font><br></div><div><br></div><div>Server/Erlang:</div><div><div><font face="courier new, monospace">** Cowboy handler bullet_handler terminating in websocket_handle/3</font></div>
<div><font face="courier new, monospace"> for the reason error:badarg</font></div><div><font face="courier new, monospace">** Message was {text,<<194,131,107,0,7,116,101,115,116,105,110,103>>}</font></div></div>
<div><font face="courier new, monospace">[...]</font></div><div><font face="courier new, monospace"><div>** Stacktrace: [{erlang,binary_to_term, [<<194,131,107,0,7,116,101,115,116,105,110,103>>],[]},</div><div>
[...]</div></font></div><div><br></div><div>Calling term_to_binary/1 using "testing" returns <font face="courier new, monospace"><<131,107,0,7,116,101,115,116,105,110,103>></font>, 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?</div>
</div>