Load testing phoenix channels

I am trying to smoke test my server, trying it out locally first. But I can’t get the test tools connected via the socket.

I’ve tried https://k6.io/docs/examples/websockets and https://github.com/Fitblip/wsstat but they refuse to connect to my local server. I know that the channels work though.

Is there a tool that does work? And how are phoenix channels different from other implementations?

I’d love to know the answer to this too. I’ve been trying to get K6 going for a few hours and keep getting the:

[debug] LiveView session was misconfigured or the user token is outdated.

1) Ensure your session configuration in your endpoint is in a module attribute:

    @session_options [

2) Change the `plug Plug.Session` to use said attribute:

    plug Plug.Session, @session_options

3) Also pass the `@session_options` to your LiveView socket:

    socket "/live", Phoenix.LiveView.Socket,
      websocket: [connect_info: [session: @session_options]]

4) Define the CSRF meta tag inside the `<head>` tag in your layout:

    <%= csrf_meta_tag() %>

5) Pass it forward in your app.js:

    let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content");
    let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}});

But I’m going through the login and sending to csrfToken along with it. Seems to be close but I’m missing something to get it to finalize the handshake.

FYI we experimented load testing channels and liveview using K6 with some degree of success.
We built a library at last year’s SpawnFest to easily generate and run K6 load tests for a variety of scenarios, including channels and liveviews.

Support for channels and liveviews is still experimental though and could definitely be improved, but if anyone is looking for a starting point to build on (and maybe contribute back :smiley: ) the repo can be found here.