[FIXED] Websocket to reply individually?

When I setup websocket to echo the input:
image
The output message is never sent to the client.
Actually, the message is output from the function node but the exit point never delivers it.

Then I red WebSocket Node multiple clients - #4 by knolleary and tried a few things:

  • removing msg._session.id broadcasts of course
  • removing msg._session.type (i.e the string "Websocket"), and keeping msg._session.id, broadcasts too ...

Any idea why this behavior?
How to send a websocket message to only the client with the msg._session.id?
Thank you

msg._session is required if you want to send a reply to the originator. If you remove it, all ws clients that are subscribed to your endpoint will get the message.

Two things to check:

  1. Make sure that the output from your function node is what you think it is using a debug node on the output.
  2. Check your client code to make sure that it is actually connected to the right endpoint. If the client is in a web page, you can use your browser dev tools to check the flow of data.

Simple echo is not working, it should since it has everything (session id, type and payload)

Everything is checked and working, except all messages are broadcasted, even with _session.id kept:


uuid here is to identify from the client side

and from the server side, we can see both uuid and session id:

But everything is still broadcasted.

Please do a test (3 nodes). I use NR 1.2.9.

Tested and it is working fine for me.

Use WebSocket King client: A testing and debugging tool for WebSockets for testing, it lets you set up multiple client connections very easily.

I can't, it's on the LAN

So is mine. It is a web tool but, just like your own code, it sends everything from your browser.

Ah, OK, thanks.

So, injection from server and send OK.


image
But no echo.
Did you try echo?
Did you connect to both ends (entry and exit) with King client?
Could you please show me your setup and results?

Same as yours. The function does nothing but is there so I can test removal of the msg._session.

Normal operation:

Removal of _session:

OK, I understand.
I mistakenly used 2 different endpoints (from a post about websocket chat, my bad).

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.