ssbc/muxrpc

hangs when example used with pull-ws

jhiesey opened this issue · 6 comments

I was trying to use v7.0.1 in my in-progress webrtc dht with websockets (using pull-ws) and noticed that things weren't working. v6.4.0 didn't have this issue, but I figured I'd be better off going forward with the newer, refactored version.

I created a minimal example that illustrates the problem by taking the example from the readme and adding websockets. See it here: https://github.com/jhiesey/muxrpc-test/blob/master/index.js

It kinda works, but then stalls partway through and only prints:

hello, world!
1
2

I'll probably try to debug this myself soon but I'd appreciate any ideas since I think @dominictarr wrote all the modules involved!

Yes, sorry you had to hit this, too.

There are known issues with v7 and sbot rolled back to v6.4 temporarily. The hanging is one of them I also experienced.

Good to know! I actually experienced a similar issue with v6.4 as well, but I think that's almost certainly my fault since I've been writing my own complicated pull streams. I was hoping to debug that issue on the newest version, but I guess I'll dig into v6.4 instead.

sorry! yes I recommend using 6 for now, still some kinks to work out of 7, but been busy with other stuff.

also having an issue that might be related. I have an example websocket client and server that I think should work but it hangs with no output on the server or client.

server.js

const {pull, values} = require('pull-stream')
const createServer = require('pull-ws/server')
const MRPC = require('muxrpc')

const oneTen = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

const api = {
  hello: 'async',
  stuff: 'source'
}

const serverApi = {
  hello: (name, cb) => cb(null, 'hello,' + name + '!'),
  stuff: () => values(oneTen)
}

const mux = MRPC(null, api)(serverApi)

const muxStream = mux.createStream()

const server = createServer(stream => pull(stream, muxStream, stream))

server.listen(5000)

client.js

const {pull, drain} = require('pull-stream')
const {connect} = require('pull-ws')
const MRPC = require('muxrpc')

const api = { hello: 'async', stuff: 'source'}

const mux = MRPC(api, null)()

const muxStream = mux.createStream(console.log.bind(console, 'stream is closed'))

const stream = connect('ws://100.115.92.2:5000')

pull(stream, muxStream, stream)

mux.hello('world', function (err, value) {
  if(err) throw err
  console.log(value)
})

pull(mux.stuff(), drain(console.log))

Is the above correct? I tried rolling back to 6.4 but had the same issue.

wow, so the above was some weird issue with my terminal!! the above code works as expected.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.