Closed alioguzhan closed 5 years ago
same problem here. Only happens when internet connection gets reset and no luck with peer.destroy()
i think (and hope) @michelle can help us on this.
for now, i switched to redis-based peer-id system. i am keeping all users' peer ids in redis, and every time i got this error, sends a request via ajax to server to generate new id for this user. and on the success (if id generated successfully) i am reloading the page. and user gets just generated peer-id. @maasud
Yeah it seems like the websockets don't emit 'close' properly/consistently on peerserver, but I'm at a loss for why that's the case.
Any progress/workarounds here? Just ran into the same issue...
Same for me
I ran into the same problem. Is peer.reconnect an option?
Just destroy and connect. Reconnect gonna fail too
Still facing this issue. @peers please solve this issue.
@michelle : I have a temporary solution. When the peer server emits an error saying that peer id is taken, can we check if there are any active connections on the same id. If no, then the peer server can flush destroy that peer id from the server. Would this work?
Any updates here? peerjs doesn't seem to be very maintained. I might try to modify the peer server and try out your idea @shashvattrip.
Hey @ncri , yes please do. I too will try it out soon once i get a little time from my current project.
Okay, well, also a bit short on time, but hope to look into it soon. So far I got a working solution, although not a very satisfying one: after a few retries the id becomes available again...
Yes, same here. I have tried changing the peer id on id not available. But I don't want to hack it, there needs to be a straight forwards working mechanism to handle this scenario
I was able to avoid the error by passing in the same token when recreating the peer object after the connection is back. Not sure if this is ideal, but it works well so far.
If peerjs-server can be modified to remove that user, that will do. Is there a working fix now ?
same problem here. tried with peer.destroy() but nothing. Anyone can help me?
Anyone found a good solution yet? I'm using hardcoded ID's to make it easy for people to connect to each other and store local data (about the other peer), so changing ID's is not the nicest solution for me.
https://github.com/peers/peerjs/blob/master/dist/peer.js#L733 Can someone explain the meaning of this string?
I made an investigation in server code and found that issue in that string, probably. https://github.com/peers/peerjs-server/blob/master/lib/server.js#L255
So how it works now - client every time when reconnect, generate a new token, server check it and generate an error message in response. How I solve it:
const token = util.randomToken();
...
options = util.extend({
debug: 1, // 1: Errors, 2: Warnings, 3: All logs
host: util.CLOUD_HOST,
port: util.CLOUD_PORT,
key: 'peerjs',
path: '/',
token: token,
config: util.defaultConfig
}, options);
What possibly wrong could be with my solution? Because I really don't understand why we can't keep one token for a page.
Any updates on this issue? peer.destroy() is not helping...
Same problem after 4 years, I suppose there is a maintainance problem :|
Is there a id timeout or a way to stimulate the real taken status of an ID?
Hi, we are maintaining it again, but I cannot go through all old issues checking if they have been fixed or not, browsers have changed a lot.
Let me give it a look to see if I can find a solution. Of course any contribution is welcome.
As mentioned before, the close event don't work for lost connections very well. My idea is to give a unique token (password) when you connect using an ID, and if another peer connects using that ID and that token, then I will suppose it is you, and will accept your connection.
What do you think about this approach?
Hello,
technically, it would work, but I am concerned about security vulnerabilities, in this way, I can in any moment impersonate another ID and get messages that were directed to him.
If there are no other ways, your solution is better than nothing, so static token ids can works with peerJS (otherwise we would need to excange dinamic ids.. almost like another signaling server)
I would have some idea to improve security, I don't know the under code so I am telling things that could be easy or not to do, you evaluate the feasibility:
Is there possibile to check a lost connection with a timeout and autodisconnect the lost connections? Otherwise on demand (this would be lesser resource consuming), when the same id reconnect, is it possible to check if the previous connection is alive (like a ping)? if the previous answer in X seconds the new connection is refused, otherwise, the previous is closed and the new wins, is it possible?
Thank you for your time
Well, you will not be able to impersonate because you need the initial Token (password) PeerServer sent to you the first time you connected.
About your proposal, the thing is, usually you need to give few seconds to the ping to come back. And what you propose, it will work, but if you lose connection and reconnect, you may need to wait about 30 secs. That's a lot of time.
o ok, I didnt know the protocol, so seem perfect
Hello,
it seems to me that the token is already shoult be used to accept the user connection in the server, is it possible? Can you tell me if I am wrong?
in this case the problem would be that the token changes, it could by simply reloading the page if not put in a cookie or similar, as a fix, could the token be forced in the client side?
app._configureWS = function(socket, key, id, token) {
var self = this;
var client = this._clients[key][id];
if (token === client.token) {
// res 'close' event will delete client.res for us
client.socket = socket;
// Client already exists
if (client.res) {
client.res.end();
}
} else {
// ID-taken, invalid token
socket.send(
JSON.stringify({ type: "ID-TAKEN", payload: { msg: "ID is taken" } })
);
socket.close();
return;
}
What's the update for this? @kidandcat I'm also facing the same problem when I'm trying to reconnect with the same peer. Its throwing error and its getting destroyed.
We added heartbeat message from client to server. So, i think we can check it and close connection if it missed
fixed in 1.0.4+
Same error NOT FIXED yet
Still happening and is sporadic
Its killing,,,,, what to do for the error
Does PeerJS is recommended for some major projects. As these kind of errors killing the project.
Hey, this is how i reproduce this error:
if i close and re-open internet connection, it throws this error.
and i dont use random ids generated from peerserver. a client's peer id is always same and unique (i am getting it from user's primary key value from database)
It is ok while i am switchinh between my web sites pages. (i put peer initialization code in my base.js which loads in every page) ,
swtiching between pages is a kind of disconnection from server right? but why does this happen only when internet connection lost?
i handle this error under
peer.on('error')
, although i write peer.destroy() here, i doesn't work.