DEV Community

Daniel Schreiber
Daniel Schreiber

Posted on • Edited on

18

Testing STOMP websocket with Postman

With Postman v8 you can test Websockets - great! But..

When testing STOMP servers you will encounter a problem:

The body is then followed by the NULL octet.

See https://stomp.github.io/stomp-specification-1.2.html#STOMP_Frames

The only way (on windows) to get the NULL octet into the frame is by using the "binary/Base64" encoding (see screenshot below).

image

To easily convert the frame you can use Notepad++:

  1. Activate "Character Panel"
  2. Add "NULL" at the end of the frame (after all headers and body) - make sure to actually click on "NULL"
  3. Select complete frame and encode it to Base64

image

image

If you found an easier way, please comment!

Image of AssemblyAI tool

Challenge Submission: SpeechCraft - AI-Powered Speech Analysis for Better Communication

SpeechCraft is an advanced real-time speech analytics platform that transforms spoken words into actionable insights. Using cutting-edge AI technology from AssemblyAI, it provides instant transcription while analyzing multiple dimensions of speech performance.

Read full post

Top comments (7)

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
 
putilovai profile image

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

Collapse
 
limaral394 profile image

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
 
benayat profile image
benayat

if you want something easier and user friendly, use apic to test your websocket with stomp. just a chrome extention, it works out of the box: docs.apic.app/tester/test-websocket

Collapse
 
javadeveloper008 profile image
mrichardsonjr

Mr. Schreiber, I don't use the word "hero" lightly, but you are the greatest hero in American history. (Thank you for saving me hours of beating my head against the wall.)

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay