7 ms·
I made several websocket-based apps that I want to turn into Electron desktop apps where people can use them only with their friends, but WebRTC has been really
by sdegutis 8y ago
I made several websocket-based apps that I want to turn into Electron desktop apps where people can use them only with their friends, but WebRTC has been really confusing and hard to know how to get started with. Especially considering ideally I don't want to have to host a server, but all the P2P JavaScript libraries that I found seem to assume you'll at least have a server for hosting the lobby to look for peers.
- jrcii 8y agoLook into the DHT protocol
- ty_a 8y agoIirc there are some free servers you can use provided by Google and/or twilio. Edit: STUN is free, Turn is not. Been a while since I worked with those.
- chuckhays 8y agoWebRTC requires some sort of external communication channel to exchange information about how to set up the connection. (Often referred to as signaling messages). Disclaimer: Google employee, work on the WebRTC team.
- marknadal 8y agoGrandparent: After getting frustrated with all the other WebRTC libraries over the last 4 years, I finally wrote our own ( https://github.com/amark/gun/blob/master/lib/webrtc.js https://github.com/amark/gun/blob/master/lib/webrtc.js ) which is capable of using a set of decentralized DHT relay-peers in GUN for signaling - and once peers are already on WebRTC, they can signal (daisy-chain "DAM" as we call it) to other WebRTC peers via WebRTC! Meaning, you don't/won't have to run any servers!!! Ping us on our chatroom if you want the list of DHT peers. Parent: Chuck! Sounds like you'd be a very useful person to know. Me, Feross, etc., plenty others have been requesting additional API/protocol access over the last 4 years (some of which FireFox is adding in libdweb extension!). Any chance we could connect and chat? Ping me at mark@gun.eco ?
- anderspitman 8y agoWould it be a problem to keep a list of DHT peers in the git repo?
- marknadal 8y agoGood idea. I need to get approval they are OK with their peers being publicly listed (easy DDoS potential, we don't have code yet to [but working on it] mitigate it). I'll start one with just mine, and then others can PR to opt-in. You want to join?
- anderspitman 8y agoAwesome, thanks. I'm not actually using WebRTC (or GUN) yet, but I hope to for a project relatively soon and the possibility of not requiring a STUN/ICE server is very enticing to me.
- Orphis 8y agoIf you need to request more APIs, you should try to talk about your usecase to the WebRTC working group using the users mailing list ( https://groups.google.com/forum/#!forum/discuss-webrtc https://groups.google.com/forum/#!forum/discuss-webrtc ). Depending on the question, you may also ask on the spec Github project ( https://github.com/w3c/webrtc-pc https://github.com/w3c/webrtc-pc ). Source: Google employee, in the WebRTC WG.
- eboyjr 8y agoYou will need some sort of signal transport for sending ICE negotiation data in JSON. Because the two peers need to know how to coordinate how to connect to each other before actually connecting. It can be a websocket server, REST API, email, QR codes, carrier pigeon, etc. Also in general, I highly recommend webrtc-adapter.
- Klathmon 8y agoThe 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.
- sdegutis 8y agoI 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).
- Klathmon 8y agoYeah, 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.
- derefr 8y agoIf everybody is behind NATs (without uPnP privileges), nobody can be the "host" for connection-signalling purposes.
- Klathmon 8y agoThere 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".
- stcredzero 8y agoFor my game, I wrote a simple UDP to WebRTC datachannel proxy in NodeJS, suing node-electron, webrtc-electron and SimplePeer. My proxy only works downstream, with the upstream signalling using websockets. I'm going to move over to an all WebRTC architecture, however. https://www.emergencevector.com https://www.emergencevector.com
- kayoone 8y agoInteresting, i am working on a realtime action game and currently implemented multiplayer via websockets including authorative server, client side predicition and server reconciliation which works failry well but based on the nature of TCP, i still sometimes get some visible stutter in the movement. I guess with WebRTC you can handle things more like traditional UDP? What are your experiences vs Websockets? Did you write how you did it somewhere? Would be very interesting
- stcredzero 8y agoI got really big stutter with head of line blocking on TCP. You can make things better by conspiring to send only 1 packet messages of about 512 bytes or less, and not too often. You can register for an account on my server. WebRTC downstream seems to be working at the moment. Be sure to read the instructions, however. https://www.emergencevector.com https://www.emergencevector.com I am thinking of turning my game server into a serverless PaaS offering. I'm open to collaborating on this.
- kayoone 8y agoi emailed you regarding this ;)
- nine_k 8y agoThere's a number of decentralized networks that could send the connection info without a single central server, e.g. torrents or Dat. OTOH the time required to connect to them and pass the info would be quite noticeable. A single connection-initiation server could be the easiest solution. It won't need to withstand a heavy load.
- jessaustin 8y agoThere are probably some problems with this idea, but why not just use a popular social network or similar as the lobby? For example, if there is a twitter feed "@MyWebRTCLobby" that everyone follows, clients could just @ a tweet at it with current contact details.
- rcraft 8y agoIf random Twitter users send @mentions to "@mywebrtclobby" then no other users will likely see these tweets unless they already follow each of the various Twitter users sending the @mentions. However if you connected @mywebRTClobby with https://GroupTweet.com https://GroupTweet.com you could configure things so that any @mentions (from authorized users or anyone) would be converted into actual tweets from the @mywebRTClobby account so that all followers would actually see those tweets/contact details.
- jessaustin 8y agoHaha I don't use Twitter so I'm not surprised I got something wrong... thanks for fixing that bug.
- jsjohnst 8y agoIt used to be the case you could see all @mentions someone received, but alas not anymore.
- matthewaveryusa 8y agoYou need a STUN/TURN server, that's just how the cookie crumbles unfortunately. Blame NAT :) I used this dockerized coturn server successfully: https://github.com/strukturag/docker-webrtc-turnserver https://github.com/strukturag/docker-webrtc-turnserver