Hello,
I’m attempting to use Tsung to load test a Phoenix LiveView website over WebSocket. I’ve tried searching online for examples, but I’ve only found examples of Tsung being used with the Phoenix framework, not specifically with Phoenix LiveView.
I’ve successfully configured the XML to establish a WebSocket connection, but I’m encountering an error on the server side when sending a WebSocket message. The following error occurs when sending the message [null,"1","phoenix","heartbeat",{}]
:
09:01:59.514 [error] Ranch listener MyAppWeb.Endpoint.HTTP had connection process
started with :cowboy_clear:start_link/4 at #PID<0.11462.0> exit with reason:
{:function_clause, [{Phoenix.Socket.V2.JSONSerializer, :decode_binary, ["
[null,\"1\",\"phoenix\",\"heartbeat\",{}]"], []}, {Phoenix.Socket, :__in__, 2, [file:
~c"lib/phoenix/socket.ex", line: 517]}, {WebSockAdapter.CowboyAdapter,
:websocket_handle, 2, [file: ~c"lib/websock_adapter/cowboy_adapter.ex", line: 24]},
{:cowboy_websocket, :handler_call, 6, [file:
~c"/buildroot/deps/cowboy/src/cowboy_websocket.erl", line: 528]}, {:cowboy_http, :loop,
1, [file: ~c"/buildroot/deps/cowboy/src/cowboy_http.erl", line: 257]}, {:proc_lib,
:init_p_do_apply, 3, [file: ~c"proc_lib.erl", line: 241]}]}
It seems the server is attempting to decode the message as a binary, resulting in a function clause error. But I’m unsure why this specific function is being called, since browsing the webpage works fine.
Has anyone experienced a similar issue or have any insights on why this might be happening? Any suggestions or guidance would be greatly appreciated.
Below is the XML configuration I’m using:
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/local/share/tsung/tsung-1.0.dtd">
<tsung loglevel="debug" backend="fullstats" dumptraffic="true" version="1.0">
<!-- Client side setup -->
<clients>
<client host="localhost" maxusers="5000"/>
</clients>
<!-- Server side setup -->
<servers>
<server host="example.io" port="443" type="ssl"/>
</servers>
<!-- Adjust injection load -->
<load>
<arrivalphase phase="1" duration="1" unit="minute">
<users arrivalrate="1" unit="minute"></users>
</arrivalphase>
</load>
<options>
<option name="file_server" id="user" value="gc.csv"/>
<option name="ports_range" min="1025" max="65535"/>
</options>
<sessions>
<session name='websocket' probability='100' type='ts_websocket'>
<transaction name="1_1_Open_Connection">
<request subst="true">
<websocket type="connect" path="/live/websocket"></websocket>
</request>
<request>
<websocket type="message">[null,"1","phoenix","heartbeat",{}]</websocket>
</request>
</transaction>
</session>
</sessions>
</tsung>