Js-ipfs: how to use websockets transport in ipfs?

Created on 27 Jan 2017  路  6Comments  路  Source: ipfs/js-ipfs

Since WebRTC is no available in Web/Service Workers (https://github.com/w3c/webrtc-pc/issues/230), for now the only other option is to use WebSockets. I haven't been able to find the correct multiaddress format/string to connect to IPFS node over WS and I'm probably missing a bunch of other things. Can someone provide an example/steps of how to connect to IPFS over WS?

This is part of the #127 effort as well as overall support of Web/Service Workers #725

kinquestion

Most helpful comment

Sure! Let me know how you'd like to do that.

My current plan to move forward with #725 is to replace window with self and update the project the run the WW tests. I was gonna create a PR for each project as I go.

But if you referring merely to document this use case in particular, let me know where that should be done.

Regardless, I'm here to help as much as I can :)

All 6 comments

In a browser node, you don't have to add a WebSockets addr in order to be able to dial to a node with WebSockets.

In a Node.js node, you need to add that to your config, see:

https://github.com/ipfs/js-ipfs/blob/master/test/utils/temp-node.js#L11-L28

Or simply open the ~/.jsipfs/config file and add it directly. It looks the same as a tcp, but with the /ws appended

@diasdavid Thanks, will try this as soon as I get all the issues with running inside a WW ironed out.

Thank you @dryajov.

Also, would you like to help us with documenting this details?

Sure! Let me know how you'd like to do that.

My current plan to move forward with #725 is to replace window with self and update the project the run the WW tests. I was gonna create a PR for each project as I go.

But if you referring merely to document this use case in particular, let me know where that should be done.

Regardless, I'm here to help as much as I can :)

woa, thank you! glad to have you around!

I feel that the best way for now (until all of this primitives are common language to everyone) is that we have a mention on the README under the USAGE section, probably IPFS Core - https://github.com/ipfs/js-ipfs#ipfs-core-examples-use-ipfs-as-a-module and then a quick example of how that is achieve in the examples folder.

I believe this is now answered, let me know if this is not the case.

Also, with the new init setup, it is 100x simpler to add that websockets addr:
https://github.com/ipfs/js-ipfs#advanced-options-when-creating-an-ipfs-node

Note: today, by default, js-ipfs ships with a websockets multiaddr, so you don't even have to add one :)

Was this page helpful?
0 / 5 - 0 ratings