DEV Community

Discussion on: Testing STOMP websocket with Postman

Collapse
 
rangoy profile image
rangoy • Edited

Hi, thank you for your tips.

Inspired by your effort I found a way of adding the NULL char at the end:
It's not beautiful, but less hassle than going through base64 encoding

  1. Use a pre-request Script in an other collection (as websocket collections doesn't yet support scripts) set a variable, eg NULL_CHAR. I use the same script to get a token too.
pm.environment.set('NULL_CHAR', '\0');
Enter fullscreen mode Exit fullscreen mode
  1. Run a request in the other collection to get the token and set the variables,
  2. Use the token and variables in the messages, eg. Make sure you do not add a newline after NULL_CHAR
CONNECT
Authorization:Bearer {{TOKEN}}
accept-version:1.1,1.0
heart-beat:10000,10000

{{NULL_CHAR}}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
limaral394 profile image
limaral394@laluxy.com • Edited

For linux, setting NULL_CHAR as ^@ worked for me.
pm.globals.set("NULL_CHAR",'^@')

Collapse
 
danielsc profile image
Daniel Schreiber

Nice!

Collapse
 
fmaillardtbs profile image
fmaillard-tbs

So how to use

pm.globals.set("NULL_CHAR", '\0');

with Websockets ? Somebody succeded it ?

Collapse
 
putilovai profile image
Aleksandr Putilov • Edited

Setting environment variable didn't work for me. I used global variables
pm.globals.set("NULL_CHAR", '\0');