两种设备广告和浏览。 尝试建立连接时会出现此问题。
func session(_ session: MCSession, peer peerID: MCPeerID, didChange state: MCSessionState) {}
尝试连接时是否正常工作,但几秒后,它再次使用MCSessionState == .notConnected
进行呼叫。
尝试使用WiFi,BT以及它们之间的所有组合......
刚补充说:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSTemporaryExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
没多大帮助......仍然进入控制台(仅在iOS 10.2设备上,但是......):
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)
(广告客户是应用的名称) 使用iPhone 6S和10.2&amp; iPhone 6配9.2。 使用来自Xcode 8.2.1(Swift3)的macOS Sierra v10.12.2在Macbook Pro上运行代码。
答案 0 :(得分:3)
您是否为广告客户和浏览器保留了对MCSession对象的引用?如果正在使用的MCSession对象被解除分配,则会发生BINDING_REQUEST
个失败的消息。
答案 1 :(得分:1)
我有同样的问题,我找到了解决方案。它仍然显示一些错误,但它适用于我。
尝试按如下方式初始化MCSession:
let mcSession = MCSession(peer: self.mcPeerId, securityIdentity: nil, encryptionPreference: .none)
然后实现MCSession的证书处理程序委托方法,如下所示:
func session(_ session: MCSession, didReceiveCertificate certificate: [Any]?, fromPeer peerID: MCPeerID, certificateHandler: @escaping (Bool) -> Void) {
certificateHandler(true)
}
答案 2 :(得分:0)
如果两个设备在建立连接后继续进行广告和浏览,则当他们重新发现彼此时可能会断开连接。建立连接后,通过调用以下方式关闭浏览:
MCNearbyServiceBrowser.stopBrowsingForPeers()
如果设备继续做广告,其他设备仍然可以连接到它们。