We we're try to send unicode data to websocket, but had a crash with this error
** Generic server <0.2107.0> terminating
** Last message in was {websocket,
[126,109,126,50,49,126,109,126,126,106,126,123,34,
116,101,120,116,34,58,34,209,139,209,132,208,178,
208,176,208,178,209,139,208,176,34,125],
{misultin_ws,
{ws,#Port<0.5164>,http,false,
{10,1,5,51},
61776,undefined,
{'draft-hixie',76},
"http://localhost:7879","10.1.5.51:7879",
"/socket.io/websocket",
[{'Upgrade',"WebSocket"},
{'Connection',"Upgrade"},
{'Host',"10.1.5.51:7879"},
{"Origin","http://localhost:7879"},
{"Sec-Websocket-Key1",
"3U4 06< <86 0O0 ) 48"},
{"Sec-Websocket-Key2",
"3 6 8g. )r2 1 4 W_2,370"}],
false},
<0.2105.0>}}
** When Server state == {state,"e95bc077-5f92-4bf4-9bbc-ba98e4636d5a",
undefined,socketio_http_misultin,
{websocket,
{misultin_ws,
{ws,#Port<0.5164>,http,false,
{10,1,5,51},
61776,undefined,
{'draft-hixie',76},
"http://localhost:7879","10.1.5.51:7879",
"/socket.io/websocket",
[{'Upgrade',"WebSocket"},
{'Connection',"Upgrade"},
{'Host',"10.1.5.51:7879"},
{"Origin","http://localhost:7879"},
{"Sec-Websocket-Key1",
"3U4 06< <86 0O0 ) 48"},
{"Sec-Websocket-Key2","3 6 8g. )r2 1 4 W_2,370"}],
false},
<0.2105.0>}},
1,
{#Ref<0.0.0.4154>,10000},
<0.2108.0>,<0.82.0>}
** Reason for termination ==
** {badarg,[{jsx_eep0018,collect,3},
{socketio_data,json,2},
{socketio_transport_websocket,handle_call,3},
{gen_server,handle_msg,5},
{proc_lib,init_p_do_apply,3}]}
After insert this stupid code, every thing goes fine:
json(_Length1, Body) ->
Length = erlang:length(Body),
io:format("~n++++ Length ~p Body pn", [Length, Body]),
{Object, Rest} = lists:split(Length, Body),
io:format("~n++++ Object ~p Rest pn", [Object, Rest]),
[#msg{content=jsx:json_to_term(list_to_binary(Object), [{strict,false}]), json=true} |
handle_rest(Rest)].
socketio_data:json/2
We we're try to send unicode data to websocket, but had a crash with this error
** Generic server <0.2107.0> terminating
** Last message in was {websocket,
[126,109,126,50,49,126,109,126,126,106,126,123,34,
116,101,120,116,34,58,34,209,139,209,132,208,178,
208,176,208,178,209,139,208,176,34,125],
{misultin_ws,
{ws,#Port<0.5164>,http,false,
{10,1,5,51},
61776,undefined,
{'draft-hixie',76},
"http://localhost:7879","10.1.5.51:7879",
"/socket.io/websocket",
[{'Upgrade',"WebSocket"},
{'Connection',"Upgrade"},
{'Host',"10.1.5.51:7879"},
{"Origin","http://localhost:7879"},
{"Sec-Websocket-Key1",
"3U4 06< <86 0O0 ) 48"},
{"Sec-Websocket-Key2",
"3 6 8g. )r2 1 4 W_2,370"}],
false},
<0.2105.0>}}
** When Server state == {state,"e95bc077-5f92-4bf4-9bbc-ba98e4636d5a",
undefined,socketio_http_misultin,
{websocket,
{misultin_ws,
{ws,#Port<0.5164>,http,false,
{10,1,5,51},
61776,undefined,
{'draft-hixie',76},
"http://localhost:7879","10.1.5.51:7879",
"/socket.io/websocket",
[{'Upgrade',"WebSocket"},
{'Connection',"Upgrade"},
{'Host',"10.1.5.51:7879"},
{"Origin","http://localhost:7879"},
{"Sec-Websocket-Key1",
"3U4 06< <86 0O0 ) 48"},
{"Sec-Websocket-Key2","3 6 8g. )r2 1 4 W_2,370"}],
false},
<0.2105.0>}},
1,
{#Ref<0.0.0.4154>,10000},
<0.2108.0>,<0.82.0>}
** Reason for termination ==
** {badarg,[{jsx_eep0018,collect,3},
{socketio_data,json,2},
{socketio_transport_websocket,handle_call,3},
{gen_server,handle_msg,5},
{proc_lib,init_p_do_apply,3}]}
After insert this stupid code, every thing goes fine:
json(_Length1, Body) ->
Length = erlang:length(Body),
io:format("~n++++ Length ~p Body
pn", [Length, Body]),{Object, Rest} = lists:split(Length, Body),
io:format("~n++++ Object ~p Rest
pn", [Object, Rest]),[#msg{content=jsx:json_to_term(list_to_binary(Object), [{strict,false}]), json=true} |
handle_rest(Rest)].
socketio_data:json/2