Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

postman websocket api, "connected" - but no messages or acknowledgement from server

I can not get postman to connect to the server using websockets.

const port =5001;
io.on("connection", (socket) => {
  console.log("Client connected",socket.id);
  socket.emit("handshake","connected to backend");
  socket.on("test", (data)=>{
    console.log("test data is:",data);
    socket.emit("test", "server heard you!")
  });
}

in postman the request address is:

ws://localhost:5001/socket.io/?transport=websocket

the symptoms are: postman says it's connected. but if I try to send anything - it disconnects after a timeout. if I set the reconnection attempts to 1, it will automatically reconnect when it disconnects...

but I don't think it's actually connecting - because nothing is happening on the server (no new client connected message)

the format of messages I have also experimented with, to no avail.

42["test","i hear you"]
42[test,i hear you]
["test":"i hear you"]
{"test":"I hear you"}
42{"test":"I hear you"}
{"event":"test","data":"I hear you"}
42{"event":"test","data":"I hear you"}
42["event","test","data","I hear you"]
["event","test","data","I hear you"]

I have inspected the console results, and have not found leads there yet. what could I be missing?

like image 641
altruios Avatar asked Jan 22 '26 19:01

altruios


1 Answers

Postman v8.10.0 added support for Socket.IO, read more.

Socket.IO in Postman

Just enter ws://localhost:5001 as the connection URL and hit Connect.

Also, you can configure the client version (default: v3), handshake path (default: /socket.io), and other reconnection configurations in the request settings.

like image 53
Udit Avatar answered Jan 26 '26 20:01

Udit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!