-
Hello socket-io community ! I read many subjects about my bug, but I can't find what I'm doing wrong. My problem : Absolutely everything is logged twice in my gateway.
Here is the piece of code that check if a client can connect to my gateway :
How I subscribe to my "message" event : `
` As I said, this handler is not inside the connect event. Here how I use socket.on in client-side : `
}, []); I'm using socket.off as I saw in many Q&A, to unsubscribe the event when my React components is "unmount". I have only one emit on my "message" event in all my applications, and that one emit is called only one time, when I click a button to send a message. Here is how I emit on client-side : I'm struggling to find my error, as the more generic response I saw for this issue was to
Something important to note :
1 is connecting... (chat gateway, mine) disconnection log : After all, the main problem is when a client-1 send a message to a client-2, client-2 receive this message twice. Another important things to note, If i change my "message" logic with that => (just adding some text to the message that the server will receive to send to others clients in the room) `
` I can see of client side : I dont know if its clear, but its like the event "message" call back himself with the new message content (I added a string before emitting in the example). I can't understand why everything is logged and trigger twice, as the logic of my friend on his gateway is very similar to mine. If you need more information, feel free to ask, I'll update my post. Thank you for your help, community ! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The problem was due to an error in importation of modules, nothing related to skcet-io |
Beta Was this translation helpful? Give feedback.
The problem was due to an error in importation of modules, nothing related to skcet-io