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

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
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40165 209
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement