telehash/telehash-js

Can't reconnect to a peer?

natevw opened this issue · 2 comments

Using the sample code and instructions in #36 (comment), I am able to get peer "test2" to connect to peer "test1" the first time. The test1 process has its mesh.accept handler called and I see the "INCOMING" log it generates.

However, if I kill the "test2" process and restart it, the still-running "test1" process does not seem to ever see it. The previous link instance it had doesn't seem to be doing anything anymore, but neither does the mesh.accept handler get triggered.

If I start a new processes "test3" with a new endpoint identity, the original "test1" process does see that come in and start communicating with it.

Hey There @natevw sorry for the long delay on this one. The problem seems to be coming from the test2 restart going back to it's lowest channelID, which gets blocked by test1 (since you're not supposed to reuse ID's unless you have a new exchange.) There's some wonky timing going on to cleanup old channels which gets exacerbated when you do a SIGINT exit without sending an end to the channel.

0.3.30 has a rudimentary fix that cleans up channels on SIGINT. Problems can still arise if you restart test2 before test1 cleans up the channel id's, but I'm working on it :)

Hey to all still wondering about this. It should be thoroughly fixed as of 0.4.0 (published to npm today).