Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program crash #2

Closed
alienatorZ opened this issue Jun 20, 2017 · 10 comments
Closed

Program crash #2

alienatorZ opened this issue Jun 20, 2017 · 10 comments

Comments

@alienatorZ
Copy link

I used 2 peers connected to each other and sending direct messages when joining room. If I kill one peer the other one crashes.

Thanks!

@alienatorZ
Copy link
Author

relevant error info:

events.js:160
throw er; // Unhandled 'error' event
^
Error: underlying socket has been closed
at /home/onr/orbittest/node_modules/multiplex/src/index.js:477:37
at Array.forEach (native)
at Multiplex.destroy (/home/onr/orbittest/node_modules/multiplex/src/index.js:475:10)
at destroyer (/home/onr/orbittest/node_modules/pump/index.js:43:45)
at call (/home/onr/orbittest/node_modules/pump/index.js:50:3)
at Array.forEach (native)
at /home/onr/orbittest/node_modules/pump/index.js:70:25
at f (/home/onr/orbittest/node_modules/once/once.js:25:25)
at Stream. (/home/onr/orbittest/node_modules/pump/index.js:29:21)
at Stream.f (/home/onr/orbittest/node_modules/once/once.js:25:25)

@josselinchevalay
Copy link
Contributor

in my side i cannot use also sendTo i have this error

if (string.length === 0) return Buffer.allocUnsafe(0)
              ^

TypeError: Cannot read property 'length' of null

@haadcode
Copy link
Contributor

haadcode commented Dec 7, 2017

Hi @alienatorZ and @josselinchevalay, could you give it a try again with the latest ipfs-pubsub-room. There have been many improvements and fixes and together with new ipfs 0.27.0 it might be that the new releases fix your problems.

Let us know how it went and if you still run into problems, let's dig deeper! 😄

@haadcode haadcode mentioned this issue Dec 7, 2017
@kidinamoto01
Copy link

Hello, @haadcode
I tested the latest ipfs-pubsub-room and ipfs with Chrome. the nodes can find each other but strangely if I closed a window, there was no log for "peer left".
Can you help me?
Thanks so much ^^

@pgte
Copy link
Contributor

pgte commented Dec 11, 2017

@kidinamoto01 could you post a snippet of the code so I can take a look?

@kidinamoto01
Copy link

hey @pgte
I just cloned and ran the ipfs-pubsub-room-demo project .
the log is
libp2p.js:50 Swarm listening on /libp2p-webrtc-star/dns4/star-signal.cloud.ipfs.team/wss/ipfs/QmatTXVytmVu3K5hmuqqknFWvSSq4bMikvkWjQ9phJkPvo app.js:13 IPFS node ready with address QmatTXVytmVu3K5hmuqqknFWvSSq4bMikvkWjQ9phJkPvo app.js:23 got message from QmatTXVytmVu3K5hmuqqknFWvSSq4bMikvkWjQ9phJkPvo: hey everyone! app.js:17 peer QmSD2F3VQhpHhTo2wfMBEGDzpNeTXsaUBTWCJAWFHUK4Gi joined got message from QmatTXVytmVu3K5hmuqqknFWvSSq4bMikvkWjQ9phJkPvo: hey everyone! app.js:23 got message from QmSD2F3VQhpHhTo2wfMBEGDzpNeTXsaUBTWCJAWFHUK4Gi: hey everyone! app.js:23 got message from QmatTXVytmVu3K5hmuqqknFWvSSq4bMikvkWjQ9phJkPvo: hey everyone! app.js:23 got message from QmSD2F3VQhpHhTo2wfMBEGDzpNeTXsaUBTWCJAWFHUK4Gi: hey everyone!
strangely after I closed one window, the hello everyonestoped showing up but there was no peer left.

@pgte
Copy link
Contributor

pgte commented Dec 12, 2017

@kidinamoto01 what version of ipfs-pubsub-room are you using?
Could you post (part of) the code?

@kidinamoto01
Copy link

kidinamoto01 commented Dec 12, 2017

yes, I am using version 1.1.2
`const IPFS = require('ipfs')
const Room = require('ipfs-pubsub-room')

const ipfs = new IPFS({
repo: repo(),
EXPERIMENTAL: {
pubsub: true
}
})

ipfs.once('ready', () => ipfs.id((err, info) => {
if (err) { throw err }
console.log('IPFS node ready with address ' + info.id)

const room = Room(ipfs, 'ipfs-pubsub-demo')

room.on('peer joined', (peer) => console.log('peer ' + peer + ' joined'))
room.on('peer left', (peer) => console.log('peer ' + peer + ' left'))

// send and receive messages

room.on('peer joined', (peer) => room.sendTo(peer, 'Hello ' + peer + '!'))
room.on('message', (message) => console.log('got message from ' + message.from + ': ' + message.data.toString()))

// broadcast message every 2 seconds

setInterval(() => room.broadcast('hey everyone!'), 2000)
}))

function repo () {
return 'ipfs/pubsub-demo/' + Math.random()
}`
link: https://github.com/ipfs-shipyard/ipfs-pubsub-room-demo/blob/master/src/app.js

@pgte pgte closed this as completed in 2a1b2b7 Dec 12, 2017
@pgte
Copy link
Contributor

pgte commented Dec 12, 2017

It happens that the room was immediately trying to reconnect and failing at so, and not handling that failure well.
Should be fixed in version 1.1.3.
Care to try?

@pgte
Copy link
Contributor

pgte commented Dec 12, 2017

@kidinamoto01 also, I updated the dependency versions in the demo, if you care to check that out..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants