GithubHelp home page GithubHelp logo

cretz / webrtc-ipfs-signaling Goto Github PK

View Code? Open in Web Editor NEW
59.0 7.0 6.0 10 KB

Tech demo using JS-IPFS to do signaling for WebRTC

License: MIT License

HTML 45.88% JavaScript 19.32% Go 34.80%
webrtc ipfs js-ipfs

webrtc-ipfs-signaling's Introduction

WebRTC IPFS Signaling

This project is a proof of concept to see whether we can use IPFS to do WebRTC signaling obviating the need for a separate server.

Goal 1 - Browser to Browser Signaling

Status: Accomplished

I currently have debugging turned on so the console logs do show some details. Steps:

Navigate to https://cretz.github.io/webrtc-ipfs-signaling/browser-offer.html. It will update the URL w/ a randm hash. (Of course, you could navigate to a hand-entered URL hash on a fresh tab). Take the URL given on that page and, in theory, open it up with the latest Chrome or FF anywhere in the world (that doesn't require TURN). After a few seconds, the offer/answer will communicate and WebRTC will be connected.

Quick notes:

  • It may seem like you need some kind of server to share that URL hash, but that's just an example to make it easier. It could be any preshared value, though you'll want it unique and may want to do other forms of authentication once connected. E.g. one person could just go to https://cretz.github.io/webrtc-ipfs-signaling/browser-offer.html#someknownkey and the other person could just go to https://cretz.github.io/webrtc-ipfs-signaling/browser-answer.html#someknownkey
  • This works with file:/// on Chrome and FF too, even across each other or mixed with traditional http pages.
  • I have tested on mobile FF on Android and it works gloriously. I haven't tested any other browsers beyond Chrome desktop, FF desktop, and FF mobile.
  • For this tech demo, I just use Google's public STUN server and no TURN server so if you require TURN this won't work for you.
  • This uses js-ipfs's pubsub support which is in an experimental state. I even hardcode a swarm to https://ws-star.discovery.libp2p.io/. So it probably won't work if this repo goes stale (which it likely will). I'm also unsure how it'd hold up to any load.
  • js-ipfs is pretty big at > 600k right now.
  • You might ask, "Why use WebRTC at all if you have a PubSub connection?" The features of WebRTC are many, in fact with the latest Chrome release, I am making a screen sharing tool requiring no local code.
  • This is just a tech demo so I took a lot of shortcuts like not supporting restarts, poor error handling, etc. It would be quite trivial to have multiple subscribers to a topic and group chat with multiple offer/answer handshakes.
  • Security...not much. Essentially you need to do some other form of security (WebRTC peerIdentity? app level ID verify once connected? etc). In practice, this is like an open signaling server.

How it Works

It's quite simple. Both sides subscribe to a pubsub topic named after the preshared identifier. Then I just send JSON'd RTCSessionDescriptions back and forth. Specifically, the offer side sends the offer every two seconds until it gets an answer whereas the answer side waits for an offer then sends an answer.

Goal 2 - Browser to Native App Signaling

Status: Failing

I was pretty sure I could easily hook up ipfs/go-ipfs with pions/webrtc and be all good. Although pions/webrtc is beautifully built, go-ipfs is not and very much not developer friendly for reading code or embedding. I was forced to use ipsn/go-ipfs which re-best-practicizes the deps. I have the code at cli_offer.go and while it looks right, the JS side cannot see the pubsub messages. I have a lot of annoying debugging to do in that unfriendly codebase.

webrtc-ipfs-signaling's People

Contributors

cretz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

webrtc-ipfs-signaling's Issues

Still working on this?

Are you still experimenting here? We have libp2p pubsub talking to js pretty well now after getting a few bug fixes merged.

Not really an issue

..but I am wondering if this would work with WebRTC video, like a one-to-many broadcast?

Any Webrtc with video testing?

So, your demo of WebRTC chat seems to work great but I was seeing errors on the date of the certs?

But I am interested in audio/video webrtc calls. Have you done any experimentes with that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.