The
P2P talk I co-presented at Couchbase Connect gave me the chance to finally sit down and write a P2P mesh replication demo for iOS. This is something people often ask about here, and I wave my hands and go “blah blah Listener blah blah Bonjour”, but it’s nontrivial to actually implement.
I built it as an extension of Grocery Sync, on a “
bonjour-sync” branch, but the
P2P code is modular enough that it can be dropped into other iOS or Mac apps.
The user model is that you pop open a browser that lists the other devices on the LAN running the app, and can choose people to follow (i.e. pull from). That setting is saved persistently, and from then on any time one of those devices is online and has new changes, your app will pull the changes across to you.
As part of building this I found some limitations in Couchbase Lite; for example, SSL cert hostname validation makes it infeasible to use P2P SSL connections. I filed issues and I’ve started putting in some fixes (although not in time for version 1.1.)
My code is for iOS or Mac OS, but in the session I described the techniques in a cross-platform way. And Android supports Bonjour (under a different non-trademarked name) so the platforms should be able to interoperate.
—Jens
PS: The talk also featured Pasin’s photo-sharing app, which he’s
announced previously It’s also very cool, and shows off a completely different technique: using QR code generation & scanning to let two devices securely ‘pair’ and connect to each other.