Multipeer Connectivity - Instability with many peers

Hope "Quinn the Eskimo" is lurking about this holiday season....


My app has been using MPC for the past year - it operates in a client / server fashion. Up until now, the number of clients connecting to the server has been around 8 or less. Things have been running OK.

Recently a customer installed 12 devices and all of a sudden, I'm getting instability issues (similar to https://forums.developer.apple.com/message/95870#95870). By instability I mean, my app is going offline because it is receiving what appears to be random invitations. I have successfully reproduced the problem in the office, but I cannot for the life of me solve it (yet).


The symptom is that that the server (who is the advertiser) receives a seemingly random invitation from a peer who is already connected and in a session with the server. In fact the client (browser), once it establishes a session with the host, discontinues the browser ([_serviceBrowser stopBrowsingForPeers];) and clears the _servicebrowser instance (ie: set to nil)


In the production version of the code, I create a single peerID for the server, and then create a new session for each peer when the invitation comes through. In the re-write I did, I started and stopped the advertiser after each client connected and started the advertiser with a new PeerID - again keeping to the principle of one client per session, but this doesn't appear to have helped.


Right now, I'm at a bit of a loss and in desperate need of a fix, so I can pay my x-mas bills 🙂


Happy to send code/logs to anyone who might be able to help


Some further notes:

- using the simulator is a waste of time as its not reliable for this sort of troubleshooting. I have borrowed 20 real ipads for the testing and have only used 12 before things got too unstable

- I setup a wi-fi network which is dedciated to the the testing

- all bluetooth is disabled

- all devices (expect 1) are iPad Air's

- all OS's are 9.2 and xCode 7.2

In the production version of the code, I create a single peerID for the server, and then create a new session for each peer when the invitation comes through.

It seems like you have an asymmetric architecture (one server, lots of clients) in which case I generally recommend that you use Bonjour + TCP rather than Multipeer Connectivity. Multipeer Connectivity, as the name suggests, was designed for a small set of peers, not a large set of clients connecting to a single server.

Bonjour + TCP will scale to at least a hundred clients without any difficulties (assuming infrastructure Wi-Fi; the peer-to-peer Bluetooth and Wi-Fi interfaces have their own link-layer limitations).

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

DTS will close for the winter holidays at the end of business on Wed, 23 Dec 2015 and re-open on Mon, 4 Jan 2016.

Thanks Quinn, I kinda half expected this would be the direction I needed to take. I think it comes with a plus that if the 'server' goes into the background, I can still keep the socket alive for comms with my clients...


THanks and happy holidays

I think it comes with a plus that if the 'server' goes into the background, I can still keep the socket alive for comms with my clients…

… for short periods of time.

If you prevent your app from being suspended, typically via a UIApplication background task, you can happily network in the background without any problems. However, when you run out of background execution time (currently after 3 minutes in the case of a foreground-to-background transition) you’ll need to shut things down.

Technote 2277 Networking and Multitasking has more to say on this.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

DTS will close for the winter holidays at the end of business on Wed, 23 Dec 2015 and re-open on Mon, 4 Jan 2016.

Hi Quinn,


Thanks for your help with this issue.


Was just re-reading your original response and wanted to clarify what the limitation is that you mention in regard to the BT/WiFi link-layer.


I spent a considerable time over the holiday break trying to get a TCP/Bonjour solution ready. For the most part the comms (once the peers are connected) operates well. However I'm having a real challenge getting bonjour to operate as I expect it should. If you could help with some of your guidance on this topic it would be most appreciated https://forums.developer.apple.com/thread/29730


Thanks

Hi @300Baud,


I know it has been a long time but I was wondering if you still use the MPC framework and if you are having any issues with it. I'm trying to use it but it seems very unstable.

I responded over in the thread you created for this.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Multipeer Connectivity - Instability with many peers
 
 
Q