As in title, from my express server I send to react app a single event via websocket like below:
webSocket.to(someId).emit(WEB_SOCKET.SEND_MESSAGE, message);
why react app receive multiple events of this same type and payload?
Here is my code:
socket.on(WEB_SOCKET.SEND_MESSAGE, (payload: Message) => {
console.log("NEW MESSAGE");
});
after send from server side my client app receive 52 times of this same at once :o [![enter image description here][1]][1]
I want to receive only one time event from websocket :/
here is details of connection to ws in react app:
const SOCKET_SERVER = "http://127.0.0.1:3000";
export const socket = socketClient(SOCKET_SERVER);
socket.on(WEB_SOCKET.CONNECTION, () => {
console.log("CONNECTED WITH BACKEND SOCKET");
});
thanks for any help! [1]: https://i.stack.imgur.com/IaPSr.png