[erlang-questions] Help Using Bullet + BERT

Kolo Rahl kolorahl@REDACTED
Tue Jul 2 01:01:58 CEST 2013


@Andrew Looking at the source code, bertl.erl looks to call binary_to_term,
with the only difference being that it wraps calls in a tuple to signify
success or error. So calling binary_to_term/1 directly should work if it's
a properly-formatted BERT message.

@Loïc Yeah, I figured it was along those lines, but was hoping it was
something more easily fixed =P

@Steve I'll give that a try, thanks.


On Mon, Jul 1, 2013 at 3:54 PM, Steve Davis
<steven.charles.davis@REDACTED>wrote:

> Hi,
>
> Not sure, but you may be looking for this js snippet:
> ws = new WebSocket(ws_url, ws_protocol);
> ws.binaryType = "arraybuffer";
>
> /s
>
> 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/b588d5aa/attachment.htm>


More information about the erlang-questions mailing list