Hi, I am building an app that depends on multiple iOS devices connecting to a designated "coordinator" iOS device. I am using MPC, and it works great when the devices are connected to the same WiFi AP, with virtually 100% connection success. My definition of success is a near instant detection of available devices, >95% connection success rate, and a stable ongoing connection with no unexpected disconnects.
The issue arises when the devices are not connected to the same WiFi network (or connected to no network with WiFi and bluetooth still on). Devices detect each other immediately, but when initiating a connection, both devices initiate a handshake, but the connection is not successful. In the few times where the connection succeeds, the connection quality is high, stable, and doesn't drop.
Is this a known limitation of the framework? Could I be doing something wrong in my implementation?
So, the first recommendation I'd give is to not use Multipeer Connectivity. Quinn has an entire post dedicated to the topic here, but the summary is that the Network Framework can do everything MPC does only... better.
In terms of the specific issue you've described, I have a few comments:
I am using MPC, and it works great when the devices are connected to the same WiFi AP, with virtually 100% connection success.
This is relying on "standard" Bonjour communication and is generally quite reliable. Indeed, the most common issue I've seen here is MPC’s peer ID architecture interfering with its own connectivity.
The issue arises when the devices are not connected to the same WiFi network (or connected to no network with WiFi and Bluetooth still on). Devices detect each other immediately, but when initiating a connection, both devices initiate a handshake, but the connection is not successful.
A lot of the behavior here depends on both what you're actually "doing" (how many users connecting, how long they're connecting, etc.) and external factors (local physical environment, number of nearby devices, etc.). However, the main issue here is that peer-to-peer WiFi relies on the devices setting up a private network amongst all clients, which can break as the number of devices involved increases. Trying to do short-lived connections with a large number of devices doesn't really work.
The Network framework itself won't really change that limitation; however, it does give you much more direct control over all of your connections, so it generally does work better than MPC.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware