A year wasted? What I learned about WebRTC & Filesharing

Seshi started out at as an optimistic idea for a University final year project to create a device agnostic distributed file storage network to support sending files peer to peer & a sudo backup platform.

What ensued was a years exploration into WebRTC, its history, web standards and learning a little about the UKs mobile phone network.

Update: We now have a simple video showing how to use Seshi:

Seshi

tldr; Web Standards are important, don't ignore them. The browser war rages on, and those that contribute to open standards are winning, by far.

Direct Peer To Peer File Sharing in the browser

Most file sharing services require something to be installed, collect user data or adopt a client/server model (which makes it challenging to scale with big ££).

WebRTC has shook up this model and now peer to peer voice chats with video and file transfer are almost commodities to add as a widget to a webpage.

Seshi Homepage Meet Seshi. Another way to send files instantly across devices.

◌ There seems to be a rekindling of interest in peer to peer applicators which is reminiscent of the 90s-2000s where peer to peer was finding its feet, getting sued, getting hyped. ◌

Of course it's note quite that simple (yet). The reality check for WebRTC in the browser to build peer to peer applications is that some form of signalling is still required (usually a server), and turn servers when true IPv6 isn't there or some other NAT issue occurs.

Haven't we solved file transfer already?

Yes & no. File sharing has been around for ages, granted. Among the most popular modern services at the moment are bit-torrent, WeTransfer, Dropbox and the amazing Infinit - check out their fantastic infinit.sh which has much the same philosophy as Seshi.

However, those all need an application to be installed on the users computer (how 90s!) which sucks for user experience. WebRTC takes this annoyance out of the equation for file sharing.

infinit.sh is certainly leading the way with their approach to device agnostic storage, if your interested in commanding a secure and distributed storage network seriously take a look at their amazing work.

When a user simply wants to send a file to a friend, users shouldn't have to insist their friend also installs something or get an account.

The web browser is claiming its place as the universal interface for applications. Don't make me install something that my browser can already do.

Since WebRTC has started to enter the mainstream web, the file sharing landscape has really shook up. WebRTC enables real-time communication between browsers, per to peer. This has re-energised the peer to peer model in computing, not to mention investment.

A few browser based examples:

Two notable additions include Torrent Time, which allows video streaming of torrents and Butter Project which is an open project aiming to be "A revolutionary way of gathering, sharing and watching video content". What's not to love about the web right now?

The original proposal

The original proposal for Seshi was to chunk files and distribute them among as many different devices as possible, duplicating chunks for redundancy.

Original Seshi proposal

Heck, it even had a mission statement:

Seshi is a Distributed file system for universal backup free for everybody.

A distributed platform (storage) which provides: Redundancy
High Capacity
Fast fetching
Free
Ungradable on the fly. Or protocol with extensibility

What bright eyed graduate dreams they were...

What happened

Seshi.io is the result of this work, but as ever there's room for improvement! Please feel free to feedback and have a play!

What Seshi does not do:

  • Create a bit-torrent like swarm (not yet?)
  • Claim to be highly secure (See Tails project or Tor for that sort of thing.

What Seshi does do right now:

  • Chunked storage of files using IndexedDB
  • Send files direct peer to peer using the browser
  • Playback of stored files (music & video)
  • Firefox & Google Chrome Compatibility
  • Mobile & tablet support (Android)

Seshi.io

What's coming

  • Play in sync with a friend!
  • Resumable transfers (because files are chunked, this isn't too far away. Done!
  • Considering an ambitious integration with the fantastic infinit.io / infinit.sh (Who's game?)
  • Safari & Edge

Seshi.io Playing back video in Seshi (above).
For the media player, we're using the beautifully made plyr by Sam Potts.

Storing large files in IndexedDB and sending them over a WebRTC Datachannel proved challenging. Depending on browser compatibility, Web Workers are used to store chunks of the file. Chunking is also done on-the-fly as files are added, and then files reassembled from their chunks to the original file.

As chunks arrive from a peer they are stored in the receivers IndexedDB and the user can then see/download/playback the file.

There's also chat functionality so peers can chat (text, not audio) whilst exchanging files- because scope creep.

The code

The code is (mostly) split into three parts, Seshi Signal, Seshi API & Seshi Skin.

The intention being to create cheap, 'throw away' Sehshi signalling servers and a reliable low-barrier to entry API with Storage + Webrtc + signalling built in. This makes Seshi very accessible, possibly scalable.

Collection of varios SIM cards of different Mobile operators Signalling servers are relatively cheap, and can even be ran from a mobile phone. In the UK at least, it turns out most 3G/4g operators put you on a NATTED IP, whereas some will lease you a totally public ip. Perfect for running small nimble signalling servers, mileage may vary!

Finally an overlay network in which peers become signalling servers is a (slight dream) to help technologies like web torrent achieve some sort of Chord routing between peers at the browser level.

Please have a play with Seshi feedback welcome!

Thank you web

Thanks to not operating in a silo the web is still innovating, its creating jobs, startups (heck, even we're having a crack at it with Seshi). Its all testament to an open approach to the web and the old adage by David Clark:

"We reject kings, presidents and voting. We believe in rough consensus and running code"

Here's to that and lets see what else can be thrown at the web, like putting users back in control of their content.

Many useful links for learning WebRTC and alike

For anyone interested in this stuff...

A good place to start: WebRTC Spec

The various stages of creating WebRTC sessions and negotiating connections: Lifetime Of A WebRTC Session

Books

WebrtcBook By Alan B. Johnston is probably the most comprehensive explanation of WebRTC, its history and influences in relation to traditional telephone networks, SIP and clear concise explanations of the various ways to implement it.

Tons of Simple WebRTC related examples

Get excited with all of Sam Dutton's, talks / code samples are a joy to read and can't be recommended enough. find them at Simpl.info

Video / Voice chat example

Talky.io is one of the very early 'Skype-like' example applications of WebRTC by &yet who also have done many very informative talks at web dev events on WebRTC. Check out Philip Roberts's excellent talk on the event loop. They offer Realtime Consulting

Video lecture explaining WebRTC in detail

http://vimeo.com/47682405

Serverless WebRTC

It's not impossible to do signalling without a signalling server (as the WebRTC book points out, you could use smoke signals if your wanted). Usability and milage may vary.

http://blog.printf.net/articles/2013/05/17/webrtc-without-a-signaling-server/

Is an example by Chris Ball of how signalling servers could be taken out the equation, at least for forming an initial connection.

Powerpoint: How STUN and TURN works

STUN and TURN protocols are used to establishe connectivity between peers. TURN is a fallback for when this is not possible. Read about Interactive Connectivity Establishment (ICE) first, which is the overarching protocol and explains why such a seemingly complex array of protocols are needed.

Powerpoint: http://www.viagenie.ca/publications/2008-08-cluecon-stun-turn-ice.pdf

Play with Seshi

-- Generating a key with Seshi can also just be done by url e.g. Seshi.io/myConectionKey but of course, you run the risk of name collision.