hypercore-protocol / p2p-multiwriter-with-autobase

p2p posting & voting workshop
69 stars 15 forks source link

Problem 2: peer disconnected = connection crash? #7

Closed SonnyAD closed 3 years ago

SonnyAD commented 3 years ago

Hi, I was testing Problem 2 again, and I noticed with 3 peers in Problem 2 that if one of the peer disconnect, then the lest 2 peers can't discuss anymore. Do you have any ideas why?

mafintosh commented 3 years ago

By Problem 2, you mean this one? https://github.com/hypercore-protocol/p2p-multiwriter-with-autobase/tree/main/problems/02

I think the stream might be closing the stdin/stdout on socket close actually. Try doing encryptedSocket.on('data', (data) => process.stdout.write(data)) and process.stdin.on('data', (data) => encryptedSocket.write(data)) instead

SonnyAD commented 3 years ago

Works good thanks.