IOS Multiuser with Xcode

Both devices advertise and browse. The problem occurs when trying to establish a connection.

func session(_ session: MCSession, peer peerID: MCPeerID, didChange state: MCSessionState) {} 

It works when trying to connect, but after a few seconds it again calls MCSessionState == .notConnected .

I tried both WiFi, BT, and every combination between ...

Just added:

 <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSTemporaryExceptionRequiresForwardSecrecy</key> <false/> </dict> 

It didn’t help much ... Still getting in the console (only on 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:39.808822 Advertiser[1149:316295] [ViceroyTrace] [ICE][ERROR] Send BINDING_REQUEST failed(C01A0041). 2017-02-06 15:17:39.948454 Advertiser[1149:316295] [ViceroyTrace] [ICE][ERROR] Send BINDING_REQUEST failed(C01A0041). 2017-02-06 15:17:40.179569 Advertiser[1149:316295] [ViceroyTrace] [ICE][ERROR] Send BINDING_REQUEST failed(C01A0041). 2017-02-06 15:17:40.591829 Advertiser[1149:316295] [ViceroyTrace] [ICE][ERROR] Send BINDING_REQUEST failed(C01A0041). 2017-02-06 15:17:41.297454 Advertiser[1149:316295] [ViceroyTrace] [ICE][ERROR] Send BINDING_REQUEST failed(C01A0041). 2017-02-06 15:17:42.547840 Advertiser[1149:316295] [ViceroyTrace] [ICE][ERROR] Send BINDING_REQUEST failed(C01A0041). 2017-02-06 15:17:44.077537 Advertiser[1149:316295] [ViceroyTrace] [ICE][ERROR] Send BINDING_REQUEST failed(C01A0041). 2017-02-06 15:17:45.601568 Advertiser[1149:316295] [ViceroyTrace] [ICE][ERROR] Send BINDING_REQUEST failed(C01A0041). 2017-02-06 15:17:47.125030 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]. 2017-02-06 15:17:48.111331 Advertiser[1149:316267] [GCKSession] Not in connected state, so giving up for participant [66CDDFCC] on channel [1]. 2017-02-06 15:17:48.111526 Advertiser[1149:316267] [ViceroyTrace] [ICE][ERROR] ICEStopConnectivityCheck() found no ICE check with call id (1724768204) 2017-02-06 15:17:48.111705 Advertiser[1149:316267] [GCKSession] Not in connected state, so giving up for participant [66CDDFCC] on channel [2]. 2017-02-06 15:17:48.111873 Advertiser[1149:316267] [ViceroyTrace] [ICE][ERROR] ICEStopConnectivityCheck() found no ICE check with call id (1724768204) 2017-02-06 15:17:48.112042 Advertiser[1149:316267] [GCKSession] Not in connected state, so giving up for participant [66CDDFCC] on channel [3]. 2017-02-06 15:17:48.113031 Advertiser[1149:316267] [ViceroyTrace] [ICE][ERROR] ICEStopConnectivityCheck() found no ICE check with call id (1724768204) 2017-02-06 15:17:48.121016 Advertiser[1149:316267] [GCKSession] Not in connected state, so giving up for participant [66CDDFCC] on channel [4]. 2017-02-06 15:17:48.121321 Advertiser[1149:316267] [ViceroyTrace] [ICE][ERROR] ICEStopConnectivityCheck() found no ICE check with call id (1724768204) 2017-02-06 15:17:48.121506 Advertiser[1149:316267] [GCKSession] Not in connected state, so giving up for participant [66CDDFCC] on channel [5]. 2017-02-06 15:17:48.121683 Advertiser[1149:316267] [ViceroyTrace] [ICE][ERROR] ICEStopConnectivityCheck() found no ICE check with call id (1724768204) 

(Advertiser is the name of the application) Using iPhone 6S with 10.2 and iPhone 6 with 9.2. Running code on a Macbook Pro with macOS Sierra v10.12.2 from Xcode 8.2.1 (Swift3).

+5
source share
3 answers

Did you save the link to the MCSession object for both the advertiser and the browser? These BINDING_REQUEST messages BINDING_REQUEST not executed if the remote MCSession object is used for deallocation.

+2
source

I had the same problem and found a solution. It still shows some errors, but it works for me.

Try initializing MCSession as follows:

 let mcSession = MCSession(peer: self.mcPeerId, securityIdentity: nil, encryptionPreference: .none) 

then implement the delegation method of the MCSession certificate handler as follows:

 func session(_ session: MCSession, didReceiveCertificate certificate: [Any]?, fromPeer peerID: MCPeerID, certificateHandler: @escaping (Bool) -> Void) { certificateHandler(true) } 
+2
source

If both devices continue to advertise and view after connecting, they may disconnect when they open each other again. Immediately after connecting, turn off viewing by calling:

 MCNearbyServiceBrowser.stopBrowsingForPeers() 

If devices continue to advertise, other devices may connect to them.

0
source

Source: https://habr.com/ru/post/1263875/


All Articles