12

我在 iOS 10 中的 MPC 应用程序中看到以下错误,我正在寻求一些帮助来解释它们。对等点连接后,会弹出以下几个错误。对等点最终连接,但它比 iOS 9 慢(似乎导致错误消息的事件发生在主线程上)。在 iOS < 10 上运行时,这些错误不会出现在应用程序中。

[ViceroyTrace] [ICE][ERROR]     Send BINDING_REQUEST failed(C01A0041).
Not in connected state, so giving up for participant [47CD8292] on channel [0].

任何投入将不胜感激!

4

1 回答 1

16

the reason and meaning of the error

NAT

In order to explain the reason and meaning of error, we have to start with NAT (you can skip this part if you are familiar with it).

NAT is a way to mapping same 'global' IP address for multiple devices in the same local network, i.e. multiple devices share same address (may be in different time, may be using different port -- NAPT), in which way we can save a lot of 'global' address and ease the depletion of ipv4 address. And also because of this, devices's local address can only be used in LAN, not outside. The datagram want to send outside will go through NAT device (always a router) which will modify the address in header to global address. One more point is devices in the different LAN may use same IP address.

                 |
                 | /------------  'Global'
          X1':x1'|/               Address
           +------------+         
           |    NAT     |
           +------------+
                 |
                 | /------------  Local
             X:x |/               Address
             +--------+
             |        |
             | Agent  |
             |        |
             +--------+

ICE

Now, we want to make to peer communicate directly, so we have to know peer's address. But as we know, the use of NAT make the address of devices just a local address which can't be used outside the Internet and fail to communicate using it. The purpose of ICE is to discover which address the peer should use to communicate directly with other peer.

Gather Candidates Addresses

The first phase it to gather candidates addresses:

  • address of its interface
  • translated addresses on the public side of a NAT (SERVER REFLEXIVE CANDIDATES)
  • (optional): addresses on TURN servers (RELAYED CANDIDATES)

In order to get the public side address, device will send a 'Binding request' to a public server (called STUN server, outside LAN) and server send back address called 'Binding response'.

Connectivity Checks

When devices has the addresses they have, they will send to other peer over the signaling channel. When peer (we call it 'R') receive list of addresses from our device (we call it 'L'), R will collect its own addresses and respond its own list. At the end of this process, it result in CANDIDATE PAIRS. To see which pairs work, each agent schedules a series of CHECKS with 'Binding request' & 'Binding response'.

L                        R
-                        -
STUN request ->             \  L's
          <- STUN response  /  check

           <- STUN request  \  R's
STUN response ->            /  check

Conclusion

So in conclusion, possible reasons before more details:

  • fail to connect to STUN server;
  • the normal failure when testing address pair;

Suggestions:

  • check the info about the phases of ICE to know the differences of ICE implementations between ios10 and others.
  • This thread is some discussions about the bug of mpc, which may inspire you.

Ref:

于 2017-03-18T05:52:58.853 回答