ios - 多点连接对等点有时无法在完美的网络条件下重新连接
问题描述
当使用 Multipeer Connectivity 框架通过“每个设备宣传服务 + 每个人邀请每个人”实现连接多个 iPhone/iPad 时,我有时会看到即使在完美的 Wi-Fi 网络条件下也无法连接的设备。
这是一个可用于重现该问题的示例项目:
https ://github.com/ralfebert/ConnectedColors/
处理 Multipeer Connectivity 会话的代码在这里:
https ://github.com/ralfebert/ConnectedColors/blob/main/ConnectedColors/ColorMultipeerSession.swift
我向 Apple 报告了以下关于此的 FB 报告,假设这是一个错误,而不是对框架/预期行为的错误使用。
问题:这确实是 Multipeer Connectivity 框架中的一个错误,还是我错误地使用了该框架?如果是错误,是否有可用于确保设备始终在良好网络条件下连接的解决方法?
FB9703076:多点连接对等点有时无法在完美的网络条件下重新连接
当使用 Multipeer Connectivity 框架通过“每个设备宣传服务 + 每个人邀请每个人”实现连接多个 iPhone/iPad 时,我有时会看到即使在完美的 Wi-Fi 网络条件下设备也无法连接。
重现步骤:
- 在多个设备上运行附加的 ConnectedColors 示例项目 ( https://github.com/ralfebert/ConnectedColors/ )(使用至少 3 个设备更容易重现)。
- 通常它们最初都成功连接,您可以更改所有设备上的颜色。
- 通过强制退出应用程序或暂停它来断开和连接其中一个设备(两者都可能导致问题发生)。
- 尝试几次后,您会看到设备无法连接。
该应用程序尝试每 5 秒重新邀请已知但未连接的对等方。有时这有助于恢复此类故障,但通常它会完全卡住。
以下是 3 台设备发生此类连接失败的视频: https ://www.youtube.com/watch?v=MDg2BlN65R4
在这些情况下,您可以在日志中看到失败的重新邀请尝试以及以下错误:
2021-10-14 12:33:01.808847+0200 ConnectedColors[1505:832300] [connection] nw_endpoint_handler_set_adaptive_read_handler [C43 fe80::60:594d:64d9:7d95%en0.49772 ready socket-flow (satisfied (Path is satisfied), viable, interface: en0, scoped, ipv4, ipv6, dns)] unregister notification for read_timeout failed
2021-10-14 12:33:01.809123+0200 ConnectedColors[1505:832300] [connection] nw_endpoint_handler_set_adaptive_write_handler [C43 fe80::60:594d:64d9:7d95%en0.49772 ready socket-flow (satisfied (Path is satisfied), viable, interface: en0, scoped, ipv4, ipv6, dns)] unregister notification for write_timeout failed
2021-10-14 12:33:01.845341+0200 ConnectedColors[1505:831238] didReceiveInvitationFromPeer <MCPeerID: 0x283678110 DisplayName = iPad>
相关资源
示例项目来自我关于使用 Multipeer Connectivity 框架的介绍性文章: https ://www.ralfebert.de/ios/tutorials/multipeer-connectivity/
ConnectedColors 项目的设置与“创建协作会话”示例项目中的设置非常相似:
https ://developer.apple.com/documentation/arkit/creating_a_collaborative_session
解决方案
推荐阅读
- angular - 角度错误:“模板解析错误:解析器错误:缺少预期:”
- react-native - onChangeText 返回之前的状态值
- transactions - Quarks 反应式 Postgresql 事务
- .net - 该事件只能出现在 += 或 -= dotnetstandard 2.1 的左侧
- python - Python:根据两个表中的部分文本匹配加入 2 个表
- rebus - Rebus SqlServerTransportOptions
- python-3.x - 我正在使用 selenium(python 模块(3.8))打开 DocDroid.net 网站并从我的桌面发送 PDF 文件。但我收到以下错误
- sqlite - 无论时区如何,如何在 sqlite 中搜索一小时?
- php - JQUERY ajax 更新 laravel 中的字段不起作用
- xml - 为什么 clojure.xml/emit 在标签内的字符串内容周围打印新行?