Socket.IO infinite loop on connection

后端 未结 2 1444
南方客
南方客 2020-12-31 11:05

Socket.IO make an infinte loop on connection ! It\'s weird and never happen until now. I don\'t know what\'s wrong. I try to rebuild the package, I copy some code from an ol

相关标签:
2条回答
  • 2020-12-31 11:32

    The problem was at the client-side, I don't load the latest version of socket.io like on the server-side. In my package.json I have 2.0.3 and at the client-side was 1.2.0.. For everyone who have this problem

    0 讨论(0)
  • 2020-12-31 11:32

    This happened to me when I emitted an array (on connection) and not an object...

    I solved it by wrapping the array with {} so I'm now sending an object... i.e {array}...

    e.g:

    myArray = [{blah:"some value"},{blah2:"some other value"}];
    
    socket.emit('target',myArray); //results in infinite loop
    
    socket.emit('target',{myArray}); //sends ok and not looping
    

    No need for socket version to match on server and client... in my case the client is c# and my server is node.js

    0 讨论(0)
提交回复
热议问题