Multipeer Connectivity in iOS 10 (Bluetooth Issues)

I have an app that has been in production for 3 years. It uses MPC to connect remotes (iphones/ipods) to an iPad for sports scoring.


In testing with iOS 10 (now on GM), I have come across the following issue:


The app works fine when all devices are on using WiFi only, i.e. everything connects. When I put all devices into Bluetooth only, I get a connect failure.


Here is my invitation code:


[_servicebrowser invitePeer:peerID toSession:_session withContext:nil timeout:30];


Here is my connection code on the iPad:


  1. -(void)advertiser:(MCNearbyServiceAdvertiser *)advertiser didReceiveInvitationFromPeer:(MCPeerID *)peerID withContext:(NSData *)context invitationHandler:(void (^)(BOOL, MCSession *))invitationHandler
  2. {
  3. if (_serverState == ServerStateAcceptingConnections && [self connectedClientCount] < self.maxClients)
  4. {
  5. NSLog(@"MatchmakingServer: Connection accepted from peer %@", peerID);
  6. invitationHandler (true, _session);
  7. }
  8. else
  9. {
  10. invitationHandler (false, _session);
  11. }
  12. }
  13. -(void)session:(MCSession *)session didReceiveCertificate:(NSArray *)certificate fromPeer:(MCPeerID *)peerID certificateHandler:(void (^)(BOOL))certificateHandler
  14. {
  15. certificateHandler (true);
  16. }


Here is the issue:


When using WiFi (Bluetooth turned off on all devices), the didReceiveCertificate method is called and passes as usual. When using only Bluetooth(WiFi off on all devices), this method is never called and the console gives the following message:


Advertiser got invite with nil connectionData.

Data from peer [Steve's iPhone,09D0CE9E] received with error Connection closed.


The connection then fails.


This is a huge problem for me as my clients rely on Bluetooth connectsion as well as WiFi.


What has changed???? The exact same code is being executed for WiFi or Bluetooth.

Same problem.


Using iPhone 6S with 10.2 & iPhone 6 with 9.2.

Running code on Macbook Pro with macOS Sierra v10.12.2 from XCode 8.2.1 (Swift3).


Tried both with WiFi, BT, and every combination in between...


Just added:

<key>NSAppTransportSecurity</key>

<dict>

<key>NSAllowsArbitraryLoads</key>

<true/>

<key>NSTemporaryExceptionRequiresForwardSecrecy</key>

<false/>

</dict>


Did not helped much... Still getting in the console (just on the iOS 10.2 device, though...):

2017-02-06 15:17:37.858063 Advertiser[1149:316236] [ViceroyTrace] [ICE][ERROR] ICEStopConnectivityCheck() found no ICE check with call id (1724768204)

2017-02-06 15:17:39.727633 Advertiser[1149:316295] [ViceroyTrace] [ICE][ERROR] Send BINDING_REQUEST failed(C01A0041).

2017-02-06 15:17:48.110301 Advertiser[1149:316267] [GCKSession] Not in connected state, so giving up for participant [66CDDFCC] on channel [0].

Each message few times...


(Advertiser is the name of the app)

Did you find a solution to this problem? I also tried to use the MPC framework but it seems really unstable and I get errors like yours. Most of the time it only works the first time the app is launched after being built to a device, or under certain combinations of bluetooth, wifi or mobile data.

I have observed a successful MPC connection over bluetooth with both devices running iOS 10.3.2. That seems to indicate that the MPC/bluetooth problem may have been fixed.

I had the same problem: "[ViceroyTrace] [ICE][ERROR] Send BINDING_REQUEST failed(C01A0041)." (even with the latest iOS 10.3.3)


Here's how i fixed it:


  • Set the session encryptionPreference to .optional
  • Implement the session delegate didReceiveCertificate with this code:

    certificateHandler(true)


Now the connection changed from .connecting to .connected


Hope it helps you 🙂

We are having this problem again on iOS15 running over Bluetooth. Session connects successfully over Wifi but never gets to connected over Bluetooth. Over bluetooth it gets to connecting state receiving the invite in didReceiveInvitationFromPeer which we handle but then never gets any further and eventually timesout. We are using the apple sample Streaming an AR Experience app ( https://developer.apple.com/documentation/arkit/streaming_an_ar_experience )

Is anyone else able to get this working over Bluetooth on iOS15?

Multipeer Connectivity in iOS 10 (Bluetooth Issues)
 
 
Q