News for hackers. Stuff that matters.
Re:How Discord Handles Two and Half Million Concurrent Voice... by Klathmon on Monday September 10, 2018 @01:22PM (#17953395)
The fact is that you can't easily do the last part without a central server.

There might be some public or semi-public servers for this kind of thing available somewhere, or the alternative that I played with a few years ago was to compress and base64 encode the connection information into a string, and allow users to share the link with friends via whatever method they want, and that can then be expanded client side and used to establish the connection. (Or something like qr codes I've also seen used)

Sadly I never finished that project, so I don't really have any code to show you, but in theory it should work okay.

Re:How Discord Handles Two and Half Million Concurrent Voice... by kaoD on Monday September 10, 2018 @02:10PM (#17953717)
> base64 encode the connection information into a string

Doesn't work anymore.

Firefox times out the answer offer after very few seconds, which makes sharing the answer offer asynchronously impractical, which effectively killed serverless WebRTC and in turn killed any interest I had on it (for my side projects I mostly do serverless web apps, as in real serverless, not lambda functions).

Re:How Discord Handles Two and Half Million Concurrent Voice... by Klathmon on Monday September 10, 2018 @02:20PM (#17953806)
Ouch! That really sucks...

Is there a ticket number or blog post or something I can research to learn a bit more about the reasoning behind this change with them?

Re:How Discord Handles Two and Half Million Concurrent Voice... by kaoD on Monday September 10, 2018 @03:43PM (#17954533)
No ticket that I know of. It's mentioned in https://blog.mozilla.org/webrtc/ice-disconnected-not/

> So every 5 seconds Firefox (version >= 49) sends another binding request no matter if the ICE transport is in use or not, and it expects the other side to reply with a binding response. If it hasn’t received a binding response for 6 consecutive binding requests, in other words no reply within the last 30 seconds, it will give up and mark the transport as failed. This results in switching the ICE connection state to ‘failed‘ and stop sending any packets over that transport.

Re:How Discord Handles Two and Half Million Concurrent Voice... by api on Monday September 10, 2018 @02:33PM (#17953935)
Zero-config peer to peer is basically impossible without central servers or some large populated list of long-term seed nodes which are basically central servers.

The central servers don't have to do much, but they need to exist so new nodes on random IPs can find each other. The Internet has no native service discovery bus.

Re:How Discord Handles Two and Half Million Concurrent Voice... by hobo_mark on Monday September 10, 2018 @03:13PM (#17954255)
Could I avoid requiring a central server, and still use webrtc, if the two peers I want to connect are in the same lan?
Re:How Discord Handles Two and Half Million Concurrent Voice... by dep_b on Monday September 10, 2018 @04:12PM (#17954805)
Yes: https://github.com/LucasVanDongen/WebRTC-Local-Loop-iOS

Based on: https://webrtc.github.io/samples/src/content/peerconnection/...

You will need to know where the other peer lives. Which is why they expect you to have a discovery service. But typing in local IP's should work for internal networks. The hardest part is getting through NAT and firewalls and that's not a problem on your own LAN.

Re:How Discord Handles Two and Half Million Concurrent Voice... by api on Monday September 10, 2018 @03:18PM (#17954305)
I think this is possible, but I'm not sure about the details. I think their IPs need to be obtained somehow though. I don't think you can use things like mDNS from web pages without a plugin.
Re:How Discord Handles Two and Half Million Concurrent Voice... by singularity2001 on Monday September 10, 2018 @03:35PM (#17954461)
would ip guessing work? 192.168.. … ?
Re:How Discord Handles Two and Half Million Concurrent Voice... by api on Monday September 10, 2018 @03:40PM (#17954507)
It would flood the network with probes and take quite a while.
Re:How Discord Handles Two and Half Million Concurrent Voice... by mcdevilkiller on Tuesday September 11, 2018 @04:43AM (#17958086)
Maybe embedding nmap with the electron app to search for active bodes, then probeing. Requires some C or C++ knowledge though.
Re:How Discord Handles Two and Half Million Concurrent Voice... by singularity2001 on Tuesday September 11, 2018 @08:32AM (#17959092)
can't electron js do local pings?
Re:How Discord Handles Two and Half Million Concurrent Voice... by matthewmacleod on Monday September 10, 2018 @03:43PM (#17954534)
You still ultimately need some channel to set up that initial P2P connection. This allows the peers to share the IP addresses at which they’re accessible, as well as the formats and codecs they each support.

There’s nothing to stop you doing this through broadcast messages on a local network, though I’m not aware of any way that could be done from within a browser. You could extract the SDP and ICE messages from the browser environment and handle that in Node though, if you were using Electron or something.

Re:How Discord Handles Two and Half Million Concurrent Voice... by hobo_mark on Monday September 10, 2018 @05:29PM (#17955374)
Thanks everyone, what I essentially want to do is link a phone (my app) with a laptop (running a decent browser) by showing a QR code on the latter, and establish a data channel (not voice or video).
Re:How Discord Handles Two and Half Million Concurrent Voice... by sdegutis on Monday September 10, 2018 @01:48PM (#17953553)
I mean if everyone already has a way to contact their friends (discord) and say "hey let's play this game together", sharing that link does away with the need for a coordination server. But there's still the need for at least a server, even if it's just one of the clients that knows how to take charge (like Minecraft).
Re:How Discord Handles Two and Half Million Concurrent Voice... by ObsoleteNerd on Monday September 10, 2018 @02:10PM (#17953722)
The link could just be encoded information that gives the hosts details for everyone else to connect to.
Re:How Discord Handles Two and Half Million Concurrent Voice... by Klathmon on Monday September 10, 2018 @02:01PM (#17953644)
Yeah, I skipped over a lot of the details, but you would need someone to choose to be a "host" (at least in terms of a "host" for the connection signaling stuff), but you can also implicitly make it the person who created the link safely.
Re:How Discord Handles Two and Half Million Concurrent Voice... by derefr on Monday September 10, 2018 @03:08PM (#17954211)
If everybody is behind NATs (without uPnP privileges), nobody can be the "host" for connection-signalling purposes.
Re:How Discord Handles Two and Half Million Concurrent Voice... by Klathmon on Monday September 10, 2018 @03:30PM (#17954415)
There are public ICE/STUN servers that can facilitate NAT-punching, google even hosts one. But that's not the aspect that I thought the root comment was talking about, but more the aspect of "A is hosting a room called 'stuff', and B and C want to browse the list of rooms and connect to it".
Re:How Discord Handles Two and Half Million Concurrent Voice... by DINKDINK on Monday September 10, 2018 @03:12PM (#17954246)
>The fact is that you can't easily do the last part without a central server.

Looks up DHT use.

Re:How Discord Handles Two and Half Million Concurrent Voice... by Klathmon on Monday September 10, 2018 @03:32PM (#17954443)
DHT is a fantastic system, but it's not easy by any means, and it still needs some "important" nodes to help bootstrap the system.