-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Manually connect to signaling server #2508
Comments
Unfortunately no, and really not being able to connect to the signalling server should not bring the node down (or at least there should be an option to allow). Please be aware that the "*-star" protocols are being phased out in favour of relay and distributed signalling. See more here libp2p/js-libp2p#385 |
Thanks @alanshaw! I had a look at the issue you linked to but found it unclear what my alternatives are. Is it still a work in progress, or is there some other way of discovering other browser nodes that is available now? |
Devil in the details :-) We switched to js-libp2p-websocket-star-multi some time ago. TL;DR: If you have only one ws-star configured, it becomes a single point of failure. @oed Try adding 2-3 backup signaling servers to make your setup more robust, or set |
Thanks, that's very helpful @lidel! |
The user may start the node with no swarm addresses to speed up startup times - if they then use libp2p to listen on new transports we should return the addresses currently being listened on instead of those configured at startup. refs #2508
The user may start the node with no swarm addresses to speed up startup times - if they then use libp2p to listen on new transports we should return the addresses currently being listened on instead of those configured at startup. refs #2508
Since the async/await refactor of ipfs and libp2p a lot has changed behaviour wise. You can now specify no swarm multiaddrs during startup and use It'll also not explode if some of the addresses are unlistenable on (try adding the multiaddr '/dns4/star-signal.cloud.ipfs.team/tcp/443/wss/p2p-webrtc-star' to the Apart from that the same caveats apply though - you must pass some addresses to N.b. you can't use js-libp2p-websocket-star-multi or js-libp2p-websocket-star with the new ipfs or libp2p right now as they've yet to be refactored to support the new async/await transport API. |
The user may start the node with no swarm addresses to speed up startup times - if they then use libp2p to listen on new transports we should return the addresses currently being listened on instead of those configured at startup. refs #2508
The user may start the node with no swarm addresses to speed up startup times - if they then use libp2p to listen on new transports we should return the addresses currently being listened on instead of those configured at startup. refs #2508
Ack, I believe the plan is to not port websocket-start and switch to new websocket stardust transport (cc @vasco-santos: where this work can be tracked?) |
That's true, we are going to release |
@vasco-santos is the
|
Hello @oed Thanks for reaching out. Are you able to use Bear in mind, that both these libp2p transports need the signalling server. The public deployed signalling servers are still outdated AFAIK. If they got updated, people still relying on them would also have issues. The best option for this is to have your own deployed, since these servers availability is not guaranteed. Check this recent twitter thread for more information: https://twitter.com/vascosantos10/status/1262769647482482689 If this does not help you let me know, and we can discuss further here. |
Thanks, yeah as I mentioned we are deploying our own instance. What's the reason you are recommending This is the webrtc package you are talking about right? https://github.com/libp2p/js-libp2p-webrtc-star The reason I'm hesitant about using that is that we where running into issues in firefox last time we tried it. Also as you can see in this issue: #3022 webrtc is not supported if you want to run ipfs in a worker, which we intend on doing in the future. Any other reason not to use |
@oed The reason for recommending
Yes!
I would not worry about this for now. Our goal is to get rid of the start servers during the next couple of months and fully rely on circuit relay nodes and the libp2p/js-libp2p-rendezvous protocol (libp2p/specs/rendezvous). The circuit relay is already implemented and you can use it in the browser context. The main reason that we still need to use a FYI, I just started working on the rendezvous protocol a couple of days ago and it will be my main focus for the following weeks. You can expect this to be released in |
Thanks again @vasco-santos, very helpful. Will definitely try using |
Let me know if you hit any issue @oed |
Actually, in chromium I get the following error when opening to separate tabs (one normal, one incognito), that connect to the same webrtc-star: Trying to manually connect one node to another doesn't work either. Could this be due to some simple misconfiguration @vasco-santos ? |
Can you point me in a repo so that I can give it a try? I will try to test this out over the weekend and get back to you. A repo, or the configuration + app code running |
Thanks @vasco-santos! It will throw the errors above if:
|
I have done some experiments with this and I have found several things that we need to consider, but I would like to explain this by parts. First of all, I grabbed your example, but used it as I recommend you should: const opts = {
preload: { enabled: false },
config: {
Bootstrap: [],
Addresses: {
Swarm: ['/dns4/p2p.3box.io/tcp/9091/wss/p2p-webrtc-star/']
}
}
}
Ipfs.create(opts).then(ipfs => {
window.ipfs = ipfs
ipfs.libp2p.on('peer:discovery', (peer) => {
console.log('discovered', peer)
})
ipfs.libp2p.on('peer:connect', async (peer) => {
console.log('connected', peer)
ipfs.swarm.peers().then(peers => console.log('current peers connected: ', peers))
})
}) With this, I tested chrome and firefox. In Chrome this just worked as expected. I start one peer and it logs its swarm listening address. When I start another peer in an incognito window, they both log that they discovered the other peer and then they both log that they are connected to it. In Firefox, I got some problems. I started one peer in and it logged the swarm listening address as expected. Then, I tried to start a new node in an incognito window and basically nothing happened. With that, I tried to test one node in chrome and one node in firefox, which also worked. I ended up figuring out what was causing this and if you use 2 chrome tabs the same thing happens. Browser compatibilities life 😢 What is the "problem"? In firefox (any window) and chrome (same window), an IPFS node will use the same ipfs repo. This way, when we start a second node, it will simply not start because there was one peer already running. So, I tried out setting a random repo string in the configuration for test purposes: const opts = {
preload: { enabled: false },
repo: Math.random().toString(36).substring(7),
config: {
Bootstrap: [],
Addresses: {
Swarm: ['/dns4/p2p.3box.io/tcp/9091/wss/p2p-webrtc-star/']
}
}
}
Ipfs.create(opts).then(ipfs => {
window.ipfs = ipfs
ipfs.libp2p.on('peer:discovery', (peer) => {
console.log('discovered', peer)
})
ipfs.libp2p.on('peer:connect', async (peer) => {
console.log('connected', peer)
ipfs.swarm.peers().then(peers => console.log('current peers connected: ', peers))
})
}) This configuration guarantees that each tab/windows will have a node running with a random repo. As a consequence, any time we open a tab/window a new node is created and the other is discovered and connected. I could have this working on Chrome and Firefox without visible issues. The question here, is if this is what is expected to happen? @Gozala is working on defining this on ipfs/js-ipfs#3022 and provide your thoughts on it. If we should expect that a node should be shared between tabs, this type of tests would not be possible between two tabs in a browser for example. Anyway, this is out of the scope of this issue, should to point you on the uncertainty in this topic. In your previous comments, you mentioned that you were doing a manual dial. While you are able to, I would recommend just having the peers dial themselves automatically after discover, since this is the default behaviour of const opts = {
preload: { enabled: false },
repo: Math.random().toString(36).substring(7),
libp2p: {
config: {
peerDiscovery: {
autoDial: false
}
}
},
config: {
Bootstrap: [],
Addresses: {
Swarm: ['/dns4/p2p.3box.io/tcp/9091/wss/p2p-webrtc-star/']
}
}
}
Ipfs.create(opts).then(ipfs => {
window.ipfs = ipfs
ipfs.libp2p.on('peer:discovery', (peer) => {
console.log('discovered', peer)
})
ipfs.libp2p.on('peer:connect', async (peer) => {
console.log('connected', peer)
ipfs.swarm.peers().then(peers => console.log('current peers connected: ', peers))
})
}) With this, you can do Bear in mind that if you are using a webapp and your friend in a different laptop is using the same web app via the same signal server, this should just work, since each of you will have a different ipfs repo, a consequently a different peer ID. I could not reproduce your issues in the attached pictures though. I have Firefox 76.0.1 and Chrome 81.0.4044.129. I had my chrome opened for 15 minutes, with both peers connected. From the output, it seems related with the webrtc protocol. Could you try with the code that I provided above and if the same problems occur let me know with the full outputs. But, I have an idea for the last one, the operation aborted. Since a few versions ago, |
Using a random repo for each instance makes sense. Figured out the main issue, however I'm still seeing inconsistencies. Browser versions: Now whenever I open the example I discover a node with PeerId: I was having the errors below until I disabled my VPN. After my VPN was disabled I was able to connect to peers on my own computer. Connection errors with VPN enabledWhen I open any combination of browsers and tabs I get these errors when it's trying to connect. In Firefox it looks like this:In Chromium and Chrome it looks like this:iOS Safari issuesOnce I figured out that the issue was because I had a VPN enabled I wanted to try to see if this worked on mobile. I simply loaded the example in Safari on ios, however I'm not seeing any new peers show up in my console on my desktop browser (have not set up console in mobile). Is there any reason this would not work on mobile? Testing with a friendAsked a friend to load the same page though ngrok. Using Chrome same version as above. We are completely unable to establish a connection between our two browsers. Seeing the same issue in the console as in the images above. ConclusionUnless I'm missing something it seems like the webrtc star is still quite fragile, and not as usable as Edit:We're not really interested in doing manual dials btw. Automatic dial is what we need. |
Hey @oed Regarding the VPN issues and iOS Safari, I would ask you if you could open an issue on libp2p/js-libp2p. We need to consider and test this in libp2p. Could you get this working with stardust? Rendezvous is on its way to hopefully solve all these issues. |
Hey @vasco-santos sorry for the slow response here. We are currently going ahead with webrtc-star. Will post new issues there. This particular issue (Connecting to signaling server after ipfs construction has been solved by #2508 (comment)) |
Type: Question
Low - An optional functionality does not work.
Severity: Low
Description:
I'm trying to figure out if it's possible to connect to a signaling server without putting it in
config.Addresses.Swarm
. I have two main reasons for this: 1. webrtc-signal can make ipfs throw an error when starting if the user has a plugin that blocks webrtc, 2. starting ipfs with signaling servers makes the startup a few seconds slower.I've tried connecting to signaling servers using
ipfs.swarm.connect
(both with and without peerIds), but this throws errors, e.g.Is there some other way of connecting to a singaling server without specifying it in the initial config?
The text was updated successfully, but these errors were encountered: