WebRTC ipfs chat

So we're going to build a little chat application that combines a couple of interesting Web technologies. First, if you don't already know, this site is hosted on ipfs. That means the "servers" hosting it are distributed across a wide network. At the time of this posting my local ipfs daemon is connected to 808 peers.

WebRTC lets us do inter-browser real-time communication (with some small caveats) from JavaScript. By hosting a simple WebRTC application we should be able to make a "serverless" chatroom.

uploaded @cjbprime's serverless WebRTC chat implementation to ipfs so I guess that's serverless twice over now? :) https://t.co/8ZCX4rsK8Q — david4096 ( @david4096 ) June 8, 2018

The caveats

ipfs webrtc chat works, and click through to see a fork of a serverless WebRTC implementation from @cjbprime. The trick is that clients need a way of discovering each other initially. In most WebRTC implementations, this is done by a server that can take connection offerings and pass them along.

With ipfs, we don't have a place to easily allow web clients to make these peer offerings. We can't expect each client to have an ipfs client installed.

To that end, this demonstration requires you to transfer your offering using some other means, like an email or instant message. The process itself can be a bit slow, but with a couple of copy-pastes you'll get an interface you can use to chat, share files, and webcam.

Pulling it all together

So, with a friend (or two Web browsers), click over to WebRTC chat on ipfs.

Combining JavaScript web applications with WebRTC, it may be possible to create very dynamic decentralized Web experiences. For example, a client with a local ipfs client connected to another over WebRTC could offer write protected services. This would allow connection offers to be published to ipfs.

Remember, WebRTC is good for more than just files! Of course, a decent game could be made using this protocol. But consider if we could safely expose the JavaScript runtime to other clients over WebRTC. Our Web browsers could connect into a very powerful computer!

I posted about this over at r/ipfs.

Go home