Search Unity

Apple recently announced that beginning June 1, 2016, “all apps submitted to the App Store must support IPv6-only networking.” Since many of our users publish Unity games to the App Store, we wanted to take a moment to discuss Unity’s support for IPv6-only networks. Note that this requirement applies to both new app submissions and updates to existing apps.

What is IPv6?

From the Wikipedia article: “Internet Protocol version 6 (IPv6) is the most recent version of the Internet Protocol (IP), the communications protocol that provides an identification and location system for computers on networks and routes traffic across the Internet.” Devices can operate on an IPv4-only network (the previous standard), and IPv6-only network, or a network with both protocols in use. Apple’s new requirement means that apps must be able to operate in an IPv6-only network.

It is important to understand that IPv4 and IPv6 networks do not interoperate, although it is possible to pass traffic from one type of network over the other with tunnelling.

Does Unity support IPv6?

Yes! WWW and UnityWebRequest are IPv6 compatible on iOS out of the box because they are based on high level Apple networking APIs. And over the past few months we have been working to bring support for IPv6-only networks to Unity’s .NET/IL2CPP libraries. Our last known IPv6 bugs related to .NET/IL2CPP were corrected in the 5.3.4p4 patch release. There is one fix pending for UNET which is going to be shipped in coming weeks. Thanks to help from great members of our community (like Exit Games) we have been able root out a number of bugs in the Unity Engine code and provide support for IPv6-only networks on the following platforms:

  • Editor: All platforms
  • Standalone player: All platforms
  • iOS
  • Android

We’ll continue to add support for IPv6-only networks on other platforms in the future.

What about older versions of Unity?

If you are using only WWW or UnityWebRequest APIs to access network resources you should be fine, though please test your games carefully.

We are also planning to backport our .NET/IL2CPP fixes to selected older lines of Unity and release them as 4.7.2, 5.1.5 and 5.2.5 updates.

What should you do?

First, test your game in IPv6-only setup to assess if all the game features work as intended. This guide from Apple goes through the setup of an IPv6-only testing network using a Mac with OS X 10.11 or later. This is the same testing that App Store reviewers will use, so it is a good place to start with IPv6 testing. Since IPv4 and IPv6 networks cannot interoperate, you must test on an IPv6-only network to ensure everything is working well. If your device has both IPv6 and IPv4 addresses, then socket operations could succeed using IPv4.

Second, audit your code for a few indicators of possible problems:

  • Look for the use of IPv4 addresses (e.g. 127.0.0.1, 8.8.4.4). Any use of such hardcoded addresses should be removed. Prefer host names, which can be used to look up the proper IPv4 or IPv6 address of a given device for the proper type of network.
  • Look for the use of the IPAddress.AddressFamily property. If the code branches based on the value of the property, is there a branch that handles IPv6 properly?
  • Look for the use of the IPAddress.Any and IPAddress.Loopback fields. These fields work with IPv4 addresses, not IPv6 addresses. Use the IPAddress.IPv6Any and IPAddress.IPv6Loopback fields as well to ensure IPv6 support.

If you encounter troubles beyond the ones mentioned above, please make sure you are using a build with the necessary fix in it. If a fix has not yet landed in your line (4.7.x, 5.1.x, 5.2.x), wait until we have released a patch with it. Then proceed to upgrade to this version.

Some of 3rd party native and managed networking plugins might also be not compatible with IPv6 networks, please consider reaching out plugin vendor for their compatibility status.

Finally, let us know if you encounter bugs in Unity related to IPv6. We will work hard to correct them as soon as possible. For issues specifically related to the App Store requirements, visit the iOS and tvOS development section of our forums. I’ll be hanging out there to help.

Update: 4.7.2 is live now: http://unity3d.com/get-unity/download/archive
Update #2: 5.2.5 is live too: http://unity3d.com/get-unity/download/archive (scroll down below 5.3.x updates).
Update #3: 5.1.5 is live too: http://unity3d.com/get-unity/download/archive (scroll down below 5.2.x updates).

55 Comments

Subscribe to comments

Comments are closed.

  1. HI,
    Does unity has any equivalent method to CAPI “getaddrinfo”?
    I tried to synthesize an IPv6 address from IPv4 address manually, by using “Dns.GetHostEntry” and “Dns.GetHostAddresses”, and none of them worked.
    We need this, because some of our submissions using fixed prefix(“64:ff9b::”) were rejected by Apple, though it works fine with our MAC sim testing pure ipv6 env.
    Any suggestion?
    Thank you!

    1. Could you please forward me (mantas@unity3d.com) rejection letter you got from Apple?
      Thanks!

    2. ALEXANDER BOGOMOLETZ

      June 17, 2016 at 4:57 pm

      I was planning to use this workaround too.
      If you find any solution to it please post here or keep in touch via email!
      Thank you!

  2. Submitted 2 bug reports:

    Socket.OSSupportsIPv6 throwing an exception on Android: https://fogbugz.unity3d.com/default.asp?803576_dd4igthvr1jva96j

    and

    Hostname only being accepted for TcpClient.BeginConnect on iOS (throws an exception on Editor/Android): https://fogbugz.unity3d.com/default.asp?803613_bnc234pfm7rrvtg7 (sync Connect() works, but seems to connect to the IPv4 ip – at least in the editor)

    1. First bug is already assigned to Android team grabbag and second one is in QA queue. Any issues that would prevent shipping game on iOS?

      1. Nothing that prevents shipping, though I’m still getting rejected :D Running their test by setting up a DNS64/NAT64 network locally through a Mac works fine, but no info from Apple about why they’re rejecting it

        1. Could you please forward rejection letter to mantas [at] unity3d.com?
          Thanks!

  3. Pavel Alieinikov

    June 6, 2016 at 8:36 pm

    Hi, I am deploying dedicated server made on UNET and when I start server I try to get list of all IPs (both IPv4 and IPv6). My server is deployed on Linux server on DigitalOcean with IPv6 support enabled, server can be pinged via IPv6 address. When I connect via IPv4 from client to server (from NetworkClient to NetworkServer) – everything works fine, however, when I connect via IPv6 – I get timeout error. I am using Unity 5.3. Strange thing is that it seems to work fine on Windows server, but doesn’t work on Linux. Can anybody help me out with this issue?

    1. Could you please make a bugreport with some small repro case attached to it and share your case number?
      Thanks!

  4. Grateful for 4.7.2 . Unfortunately it doesn’t work for me . My ipv6 code is failed . I build my ios player with il2cpp and the problem “An address incompatible with the requested protocol was used” is the same as using old unity version . The good news is that the same code works when i change the build setting to using mono(2.x) not using il2cpp . Maybe there are some bugs in il2cpp . And my work condition must uses il2cpp . Btw thanks unity .

    1. Please submit a bugreport and share your case number.
      Thanks!

      1. Alexander Bogomoletz

        June 7, 2016 at 12:41 pm

        I have similar issue in 5.4.0b20 with Udp socket when reading Socket.LocalEndpoint property.

        1. Thanks for reporting!
          Developers are looking into Socket.LocalEndpoint issue.

      2. Alexander Bogomoletz

        June 7, 2016 at 1:44 pm

        I submitted a bug with description, case 803569

      3. I have same issue in 4.7.2f1 with ” “An address incompatible with the requested protocol was used” . Does unity solve it?

  5. I am so relieved that 4.x will support this…
    Thanks Unity.

    1. Thanx.

  6. That great, could I know when will have the patch 4.7.2 release?

    1. It’s undergoing latest testing stages right now. I believe it will be out early this week. Fingers crossed.

      1. HI, I run a simplified code with version 5.3.5, exception occurred at: m_testSocket.LocalEndPoint, with “An address incompatible with the requested protocol was used”, by ignore this, everything is OK now. I will re-test 4.7.1 and 4.7.2 later. Thank you!

        1. Hmm.. Could you please submit a bugreport for 5.3.5 and share your case number?
          Thanks!

        2. HI, Mantas Puida, I’d like to, please give me a bug report url. It is the same with 4.7.1, receive operation is OK, but m_testSocket.LocalEndPoint throw an exception. Thank you!

        3. In Unity Editor activate Help menu and pick “Report a Bug…” there.

        4. I reported a bug, case 802618, thank you!

    2. HI, Our server has only ipv4 address, so We add the prefix”64:ff9b::” as you mentioned early, but it works only in one direction : it connect to the server, send data to the server(and server received it), but can not receive from the server, no data received. Receive code as follows( it works with ipv4, but not ipv6):
      m_testSocket.BeginReceive(m_rcvBuff, m_rcvBuffEnd, RCV_BUFF_SIZE -m_rcvBuffEnd, SocketFlags.None, new AsyncCallback(ReceivedDataCallback), m_testSocket);

      Any suggestion? Thanks!

      1. and our unity version : 4.7.1

        1. I believe you are hitting known issue. You should wait for 4.7.2 release, which is expected to happen very soon.

  7. Great to hear that there will be an 4.7.2 update !

    1. 4.7.2, thats nice…
      I’m glad to hear that too.
      I think Unity should not drop support for version 4.7.x until Unity 6 is out.
      Which means Unity can keep supporting the last 2 Major releases (at least) concurrently. Many big software companies do support the current major version of their software + at least 1 previous major version.

  8. Martin Nielsen

    May 13, 2016 at 9:43 am

    So, we are heavily relying on AssetBundles in our game, and are currently using 5.2.4f1 for best performance. Assetbundle loading is heavily broken in the 5.3.4 patch line.

    Any ETA on the IPV6 backport to 5.2.4f1 or a definitive Assetbundle fix for 5.3.4p1-6 ?

    We are caught between two gamebreaking issues, and are facing the possibility of not being able to publish new content.

    1. What API are you using to download Asset Bundles? If it’s WWW class then you should be fine your current version, but please do test it carefully in ipv6-only setup.

      1. Martin Nielsen

        May 17, 2016 at 3:34 pm

        Its not downloading Assetbundles that is broken, that works just fine. But everything related to Assetbundle.LoadAssetAsync() is completely broken in 5.3.4. Our entire loading structure is based on async loading, so we cant change that.

        Our next best step is to try Unity 5.3.3 and hope its IPv6 ready, as Assetbundles loading seems to be working there.

    2. 5.2.5 is out now, link is at the bottom of blogpost

  9. Rasmus Kristensen

    May 12, 2016 at 4:16 pm

    Any ETA on the patch releases for 5.1 and 5.2?

    1. We are working on them, but hopefully we will know better about actual shipment dates next week.

    2. 5.2.5 is out now, please check bottom of the blogpost

  10. i try to use the socket to connect ipv6 address, it works fine in ipv4 and ipv6 networks, but has a 10051 err code in ipv6-only network. why?

    1. Did you setup ipv6-only testing environment properly. Like can you reach http://www.apple.com from iOS device in this setup?

        1. Are you also getting similar errors in Safari on the iOS device?

      1. no. i have not got any err in safari on my device. i can access the web page.

        1. Do you have sample code to share on how are you testing it?

      2. //********** my ipv6 testing code **********
        IPEndPoint ep = new IPEndPoint(IPAddress.Parse(“::ffff:118.123.216.87”),10001);
        Socket m_Socket = new Socket(ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
        m_Socket.Connect(ep);
        //********** end code **********************
        i will get a 10051 err code in ipv6-only, bu it’s fine in ipv4. And the err occurs in API ‘Connect’.

        1. Apple NAT64 test environment seems to not like “::ffff:” prefix, use “64:ff9b::” instead as noted in https://tools.ietf.org/html/rfc6052. In general it is highly advisable to use hostnames everywhere instead of direct IP addresses.

        2. https://forums.developer.apple.com/thread/46545

          An Apple staff said

          > it is not safe to form an IPv6 address by combining an IPv4 address with the Well-Known Prefix (64:ff9b::/96). This may work in some NAT64 networks but it is not a general solution to the problem.

      3. thanks for your answer.
        today, i have changed my testing code. like this:
        //********** my ipv6 testing code **********
        IPAddress[] _ips = Dns.GetHostAddresses(“test.ts.ls.dkmol.cn”);
        IPEndPoint ep = new IPEndPoint(_ips[0],10001);
        Socket m_Socket = new Socket(ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
        m_Socket.Connect(ep);
        //********** end code **********************
        it’s fine in ipv4, but get an err message “No such host is known” in ipv6-only. And the err occurs in API ‘Dns.GetHostAddresses’.

        1. my unity version is 4.7.1.

        2. Similar code works for me fine on Unity 5.3.4p6.
          Fixes for Unity 4.7 are not yet released, we are working on them.

  11. what abou webgl sockets, is it supported there?

    1. WebGL routes all its networking through javascript (the browser) using external calls, so it uses whatever the browser is using.

  12. I just scanned our game project for any IPAddress class usage. It looks like Unity Test Tools are using this class, perhaps you guys should update that to support the new requirements?

    1. Thank you, we will look into it. Just note that use of test tools should not affect your iOS game submissions.