JJs

JJs

Error With Tsung Load Testing Phoenix LiveView WebSocket Messages

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>

Where Next?

Popular in Questions Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31586 112
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49266 226
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement