skip to Main Content

I am working on a Node.js backend project using Socket.IO and am facing two issues when trying to interact with the Socket.IO endpoints via Postman:

1. Connection and Event Emission Issue on Different URLs:
I am able to connect and emit events to the Socket.IO server when using the URL http://localhost:8000. However, when I try to connect using http://127.0.0.1:8000 or http://<private_ip>:8000, I can only establish a connection but cannot emit any events to the server. Why is this happening, and how can I fix it?

2. JSON Data Changing to String:
Even though I am sending JSON data when emitting an event, it seems to be converted to a string on the server side. How can I ensure that the emitted event data remains in JSON format? I understand JSON.parse(stringData) can solve the problem but it wasn’t needed when I worked four month back.

I dropped the node_modules, reinstall the packages, updated the packages. But it didn’t help

2

Answers


  1. Chosen as BEST ANSWER

    Well, I found the solution. The issue was causing for Postman latest version. I downgraded my Postman from 11 to 10 version. Now, it's working perfectly!


  2. Regarding #1, can you share a screenshot of what you see in POstman when you emit an event http://127.0.0.1:8000? Does the UI(or console) indicate that this event is emitted?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search