Closed AquiGorka closed 6 years ago
Hi @AquiGorka, thanks for opening this issue, now I see that it is not clear how to configure custom multiaddrs.
The fix for your issue is that you do not need that "SignalServer" on the config file, instead, you should add a multiaddr to your swarm array that looks like this:
/ip4/127.0.0.1/tcp/9090/ws/p2p-webrtc-star
So that IPFS knows where to find the Signalling Server.
The explanation why it is this way is that we use Multiaddr, a self-describable data type that offers information about an address, in the example I shared with you, we can see that 1) it is a p2p-webrtc-star multiaddr and 2) the SignalServer is available at an IPv4 addr, on a TCP port that expect interactions over WebSockets.
Let me know if you hit any other issue :)
That kind'a worked!
Now I can see all the nodes connected to the swarm. But I am not able to pubsub
between the two browser nodes - I can't find the reference but I think I read when 3 nodes are connected there can be pubsub
among them if one is not a browser
node. Am I right to assume so?
Could there be any reason why in setup like mine peers are not receiving updates via pubsub
?
Now it is working, thanks for the help @diasdavid !
Awesome! you bet :)
Would you like to contribute to the js-ipfs FAQ with how to configure a signalling endpoint?
I will gladly do so. Expect another PR from me.
I would to add that there currently is a bug with multiaddr in libp2p-webrtc-star when using domains for your signal server that listens on ports other than 80. As we have discussed @diasdavid on IRC, it is most likely util.js in libp2p-webrtc-star. I should probably create another issue, but I am pretty new when it comes to actual github usage.
Modules used:
example.com points to my IP address.
My Raspberry Pi hosts the signal server (Why isn't this module split?) and listens on port 9999
alarm@alarmpi ~ % DEBUG=* star-signal --port=9999
signalling-server signaling server has started on: http://0.0.0.0:9999 +0ms
socket.io:server initializing namespace / +0ms
socket.io-parser encoding packet {"type":0,"nsp":"/"} +0ms
socket.io-parser encoded {"type":0,"nsp":"/"} as 0 +2ms
socket.io:server creating engine.io instance with opts {"path":"/socket.io","initialPacket":["0"]} +7ms
socket.io:server attaching client serving req handler +73ms
Listening on: http://0.0.0.0:9999
Port forward my Raspberry Pi's LAN IP with internal port 9999 to external port 9999, which now make it accessable at example.com:9999
The expected multiaddr would then be (correct me if I am wrong):
/dns4/example.com/tcp/9999/ws/p2p-webrtc-star/
Add it to your ipfs config:
const ipfs = new IPFS({
repo: `stream-handler/${Math.random()}`,
EXPERIMENTAL: {
pubsub: true
},
config: {
Addresses: {
Swarm: [
'/dns4/example.com/tcp/9999/ws/p2p-webrtc-star'
]
}
}
});
Using the browser I then get this error in my console
webpack:///../node_modules/libp2p-webrtc-star/src/utils.js?:18 Uncaught Error: invalid multiaddr/dns4/example.com/tcp/9999/ws/p2p-webrtc-star/ipfs/QmRrYPJBkCQqhJ5CPq8qb8qyxd7GkRQqwPfi6mmgPFTZ9s
at cleanUrlSIO (webpack:///../node_modules/libp2p-webrtc-star/src/utils.js?:18)
at EventEmitter.listener.listen (webpack:///../node_modules/libp2p-webrtc-star/src/index.js?:134)
at eval (webpack:///../node_modules/libp2p-swarm/src/transport.js?:86)
at eval (webpack:///../node_modules/async/internal/parallel.js?:31)
at eachOfArrayLike (webpack:///../node_modules/async/eachOf.js?:65)
at exports.default (webpack:///../node_modules/async/eachOf.js?:9)
at _parallel (webpack:///../node_modules/async/internal/parallel.js?:30)
at parallelLimit (webpack:///../node_modules/async/parallel.js?:88)
at Object.listen (webpack:///../node_modules/libp2p-swarm/src/transport.js?:103)
at each (webpack:///../node_modules/libp2p-swarm/src/index.js?:77)
Assuming that the ports are accessable from the outside, use these following multiaddrs to make it work:
If port 9999 is the desired port:
/dns4/example.com:9999/ws/p2p-webrtc-star
No need to add tcp or port hackery
/dns4/example.com/ws/p2p-webrtc-star
IP4 actually works last time I checked, but I am not 100% sure. I would have to test it again.
E.g. if the desired port is 9999, then
/ip4/1.2.3.4/tcp/9999/ws/p2p-webrtc-star
Works.
/dns4 is not handled properly, and the culprit is most likely the cleanUrlSIO function. More specifically:
As it expects either ws or wss, but got tcp instead. The solution is probably adding another else if
on 'tcp' and handle it there.
I haven't gotten around to test it or looked over the code to fully understand it, but I would like to let this be my first PR on github. Just point me to the guidelines :).
As a sidenote: Chrome is a real PITA when it comes to wss and https with WebRTC as I am getting "mixed content" errors or key generation errors. I believe the provided signal server does not support wss, and I need it in order to use my own signalling server for my upcoming live demo. This also means I can't test this part.
@Steverman thank you for the complete description of the problem, 5 🌟
We are now targetting this issue in both https://github.com/libp2p/js-libp2p-webrtc-star/issues/129 and https://github.com/libp2p/js-libp2p-websocket-star/issues/35 and as we talked about, the real issue is here https://github.com/libp2p/js-libp2p-websocket-star/blob/master/src/utils.js#L8-L35. Let's continue the convo on these two issues :)
I'd been seeing some odd behavior (now reported here) so I wanted to setup a browser node that would only connect to my local
jsipfs daemon
and use my ownsignaling server
.My config looks like this:
jsipfs daemon
(using experimental pub/sub):signaling server
:I see the browser node has one connected swarm peer:
I am using
YJS
forCRDT
and I am not able to pubsub. The signaling server does not log any info - either the server does not log anything or it is not being used.Help would be much appreciated.