Socket.io message event firing multiple times

后端 未结 4 688
囚心锁ツ
囚心锁ツ 2021-01-02 10:11

I was trying to learn node and started creating a mashup with socket.io The message transportation have begin but I have run into some trouble.

The message event is

4条回答
  •  被撕碎了的回忆
    2021-01-02 10:34

    Restarting the server can be responsible for several identical event listeners on the client side. If the client has not reloaded (restarted) you have to make sure that the old event listeners are deleted on the client side when establishing a new connection. You can do that with

    io.socket.removeAllListeners()
    

提交回复
热议问题