[erlang-questions] Help Using Bullet + BERT

AD straightflush@REDACTED
Mon Jul 1 19:06:02 CEST 2013


I believe this is why tools like SockJS use their own JSON binary encoding
on the wire



On Mon, Jul 1, 2013 at 6:57 AM, Loïc Hoguin <essen@REDACTED> wrote:

> Note that bullet only supports text data right now which must be valid
> UTF-8 with some transports like Websocket. So what I'm guessing happens is
> that the browser encodes your binary to be valid UTF-8 and messes things
> up. To use binary data with bullet you need to base64 encode it or
> something similar.
>
>
> On 07/01/2013 09:03 AM, 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?
>>
>>
>> ______________________________**_________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/**listinfo/erlang-questions<http://erlang.org/mailman/listinfo/erlang-questions>
>>
>>
>
> --
> Loïc Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu
>
> ______________________________**_________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/**listinfo/erlang-questions<http://erlang.org/mailman/listinfo/erlang-questions>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130701/5ad4b4d2/attachment.htm>


More information about the erlang-questions mailing list