Using custom processor.js file to generate custom JWT header per user when load testing websockets #3438
Replies: 3 comments
-
hi @aleksandarvanced - the call to your custom function needs to be inside the VU scenario, rather than at the config:
target: "ws://localhost:8080/userMessages"
phases:
- duration: 1
arrivalRate: 1
processor: "./processor.js"
- function: "generateRandomToken"
ws:
headers:
x-jwt-token: "{{ token }}"
scenarios:
- engine: "ws"
flow:
+ - function: "generateRandomToken"
- send: "Test message"
- think: 30 |
Beta Was this translation helpful? Give feedback.
-
hey @hassy ,
Any idea what am I missing? |
Beta Was this translation helpful? Give feedback.
-
Ok i managed to fix it - here is a way how i achieved it - the documentation is a little bit confusing.
|
Beta Was this translation helpful? Give feedback.
-
Hello,
I am trying to load test a websocket server where I want to add a JWT which is different per user - and that gets passed when establishing the connection.
Here are the files
processor.js
Here is the main yaml file where the load test script is executed
The error that I am getting when executing this is
worker error, id: 1 TypeError [ERR_HTTP_INVALID_HEADER_VALUE]: Invalid value "undefined" for header "x-jwt-token"
I see there is a similar issue open here for socketio - it is closed but without any answer - #2003
Thanks a lot in advance
Beta Was this translation helpful? Give feedback.
All reactions