Jim
Jim

Reputation: 658

Is this websocket causing an infinite loop?

I'm using node red but the concept is the same for all websockets.

For demonstration purposes this image represents a basic chat app. When a user sends a message to the websocket, the websocket will send it out to all users as seen in the nodes here:

enter image description here

I am not getting any errors but isn't this type of system being called infinity?

I have looked around and this seems to be general practice. Am I just misunderstanding how sockets work?

Upvotes: 0

Views: 1313

Answers (1)

No, it's not an infinite loop. Data transmitted via WebSockets has a direction, so a server won't process data that it sent, only data that it received from someone else. (Now it's a different story if you ever connect two of these servers to each other somehow. It'd be like packet storms from old hubs.)

Upvotes: 1

Related Questions