You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When "private" connection is established messages on the receive end are printed twice (the on 'peer-msg' function is called twice).
Is it possible the socket it still open and it is sending now over both despite this line in goPrivate()? :
p2psocket.usesockets = false
As a bandaid solution, can check the time between the last message and only display it iff the difference is more than 10 milliseconds.
It is strange because as far as I can tell the message is only emitted once, and doesn't go through the server. But this p2psocket.on('peer-msg', function (data) {} still fires twice. Couldn't figure out why.
Should also be noted I'm using bundle.js instead of index.js. There is a lot more code in bundle.js, so something in there might make a difference? Haven't tried index.js to see.
After the below (copy/pasted from that issue), I went back to tackle the double-message issue and found it had gone away.
I was able to fix this by setting trickle: true in that peerOpts object.
That fixed the problem, but introduced a new one where the server would crash if either browser reloaded. The fix for that was to modify socket.io-p2p-server.js to not try to use client methods if the client doesn't exist. As in:
Line 44:
client?.emit('peer-signal', data)
That little question mark is all it took. I pulled the file out of node modules and am now referencing it directly. At some point somebody who cares about such things should make a PR for that project.
Activity
bennytheshap commentedon Apr 21, 2017
+1
NerveCoordinator commentedon Aug 26, 2018
I am also getting this issue.
As a bandaid solution, can check the time between the last message and only display it iff the difference is more than 10 milliseconds.
It is strange because as far as I can tell the message is only emitted once, and doesn't go through the server. But this
p2psocket.on('peer-msg', function (data) {}still fires twice. Couldn't figure out why.Should also be noted I'm using bundle.js instead of index.js. There is a lot more code in bundle.js, so something in there might make a difference? Haven't tried index.js to see.
jasonkester commentedon Apr 7, 2026
I fixed this inadvertently while fixing #55
After the below (copy/pasted from that issue), I went back to tackle the double-message issue and found it had gone away.