Connecting to a Cowboy server from a Node WebSocketClient… every works as expected except when a string inside and array contains a character beyond the basic ASCII set.
Client code:
//setup
Bert.convention = Bert.ERLANG;
Bert.all_binaries_as_string = true; // same outcome if false
Bert.map_key_as_atom = true;
let client = new WebSocketClient();
client.connect({serverUrl});
let __conn;
client.on('connect', function (connection) {
__conn = connection;
...
}
// example of simplest breaking version of code for send
const packet = Bert.encode(["¶"]); // example; fails with anything higher than ASCII 255
__conn.send(packet);
Server code:
// setup
-behaviour(cowboy_handler).
// handler
websocket_handle(Frame, S) ->
case Frame of
{binary, Packet} -> ConvertedPacket = binary_to_term(Packet), %% this is where the process crashes
...
{ok, S}.
I've established that I can send anything else within an array (no matter how deeply nested) and any Unicode character in a string, so long as it is not nested anywhere inside an array.
Development setup on a local machine:
Mac OS 11.2.1
Node v14.15.1
@kbrw/node_erlastic 0.1.1
Erlang/OTP 23
Cowboy 2.8.0
Connecting to a Cowboy server from a Node WebSocketClient… every works as expected except when a string inside and array contains a character beyond the basic ASCII set.
Client code:
Server code:
I've established that I can send anything else within an array (no matter how deeply nested) and any Unicode character in a string, so long as it is not nested anywhere inside an array.
Development setup on a local machine:
Mac OS 11.2.1
Node v14.15.1
@kbrw/node_erlastic 0.1.1
Erlang/OTP 23
Cowboy 2.8.0