Search Unity

Unity iOS and IPv6 support

Discussion in 'iOS and tvOS' started by Mantas-Puida, May 17, 2016.

  1. andlline

    andlline

    Joined:
    Nov 7, 2014
    Posts:
    6
    i've a problem too. My app was rejected
    "Apple said: "Please revise your app and test it on a device while connected to an IPv6 network (all appse must suport IPv6) to ensure it will launch without crashing."
    I'm using WWW class only in my app.
    Please help me !
     
  2. Mantas-Puida

    Mantas-Puida

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    You should read their reply carefully, usually they provide more information: if specific app function doesn't work or app crashes on startup. Often it has nothing to do with IPv6 support.
    In case of the crashes you should ask them to provide crashlogs and then symbolicate them against dSYM files were built when archiving app.
     
  3. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Using Unity 5.5.2p4, I got this rejection from Apple..

    "We discovered one or more bugs in your app when reviewed on iPad running iOS 10.3 on Wi-Fi connected to an IPv6 network.
    We were not able to purchase the levels, all levels were grayed out"

    To resolve this issue, please run your app on a device while connected to an IPv6 network (all apps must support IPv6) to identify any issues, then revise and resubmit your app for review.

    Seems there is issue with In-App purchases and IPv6, any ideas?
     
  4. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Did you manage to fix this issue in the end, both my iOS app and macOS app seem to be reject for similar..
     
  5. Mantas-Puida

    Mantas-Puida

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    Are you using Unity's built-in IAP or something else? Are you doing server queries when rendering your in-app shop?
     
  6. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    I'm using Prime31, StoreKit:
    https://prime31.com/docs#iosStoreKit

    Basic implementation, click buy, purchase and unlock a level.
    I tested this all before on iPhone 10.3 version and all seemed ok (with wifi network)
    I will check iPad 10.3 now with wifi, otherwise it must be IPv6 related issue.

    Not sure what you mean by server query to Apple server or private?
     
  7. Mantas-Puida

    Mantas-Puida

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    Did you test it in NAT64 environment?

    I was referring to private servers.
     
  8. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Thanks not private servers:

    Im trying to test now, but seems getting this and not on the NAT64 environment..

    Failed apple purchase - error: Cannot connect to iTunes Store
    LevelSelectMenuController:handleApplePurchaseFailedEvent(String)

    I think something weird going on Apple side..
     
  9. Mantas-Puida

    Mantas-Puida

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    Try looking into device logs, maybe there are clues
     
  10. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Rebuilding the game in Unity 5.6 and re-uploading fixed the issue.
    I think it was problem with Apple servers at time of test, but cannot say for sure.
    Thanks for listening.
     
  11. simering

    simering

    Joined:
    Jan 20, 2014
    Posts:
    4
    I also have the same issue - got rejected on Appstore but have no clue where the bug is. Anyone willing to have a look and help, please?
     
  12. igor_rst

    igor_rst

    Joined:
    Apr 20, 2017
    Posts:
    40
    Hi, we've got AppStore rejection too.
    We used sockets and code was like this, and socket didn't connected to our server:

    Code (CSharp):
    1. private Socket _socket;
    2.  
    3. public static void Connect () {
    4.     _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
    5.     _socket.BeginConnect("136.243.57.31", 11771, new AsyncCallback(OnEndConnect), null);
    6. }
    7.  
    8. void OnEndConnect (IAsyncResult iar) {
    9.     _socket.EndConnect (iar);
    10.     _socket.NoDelay = true;
    11.     Debug.Log ("connected");
    12. }
    13.  
    Version Unity 5.5.2

    We tested app in NAT64 environment, and it's not works :((
    How fix code to success run in NAT64 environment? And IPv6 support?

    UPDATED:
    so, I solved this problem for iOS. If you connect to your server by domain, you can use this function https://stackoverflow.com/a/37676501 and set correct AddressFamily.

    But if you connect to server by ip address, you should synthesize ipv6 address. Check it out http://www.codeinsect.net/2016/05/26/unity-ipv6-socket-支持

    And after that check your connection with this manual
    https://developer.apple.com/library...html#//apple_ref/doc/uid/TP40010220-CH213-SW1
     
    Last edited: May 29, 2017
    JoshPeterson likes this.
  13. sergienko88

    sergienko88

    Joined:
    Jul 22, 2013
    Posts:
    22
    Hello
    Unity 2017.2.0f3
    On mac create NAT64 network.
    Cant connect on IPv4 and IPv6 addresses via socket:
    Code (CSharp):
    1. Socket socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);//for IPv6 Addresses
    2.  
    3. Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);//for IPv4 Addresses
    Why?
     
  14. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    This should work. Do you see a specific error message when it does not?
     
  15. sergienko88

    sergienko88

    Joined:
    Jul 22, 2013
    Posts:
    22
    Code (CSharp):
    1. using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
    2.             {
    3.  
    4.                 try
    5.                 {
    6.                     var ep = new IPEndPoint(IPAddress.Parse("my.ip.v4.address"), m_connectionParams.Port);
    7.                     configureTcpSocket(socket);
    8.                     socket.Connect(ep);
    9.                     NativeHandler.NativeLog(1 + " :  done ");
    10.                 }
    11.                 catch (Exception ex)
    12.                 {
    13.                     NativeHandler.NativeLog(1+" : "+ex.Message);//Network is unreachable
    14.                 }
    15.             }
    16.  
    17.  
    18.             using (Socket socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp))
    19.             {
    20.  
    21.                 try
    22.                 {
    23.                     var ep = new IPEndPoint(IPAddress.Parse("myipv6address"), m_connectionParams.Port);
    24.                     configureTcpSocket(socket);
    25.                     socket.Connect(ep);
    26.                     NativeHandler.NativeLog(2 + " : done ");
    27.                 }
    28.                 catch (Exception ex)
    29.                 {
    30.                     NativeHandler.NativeLog(2 + " : " + ex.Message);// Protocol option not supported
    31.                 }
    32.             }
    33.  
    34.             using (Socket socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp))
    35.             {
    36.  
    37.                 try
    38.                 {
    39.                     var ep = new IPEndPoint(IPAddress.Parse("64:ff9b::" + myipv4address), m_connectionParams.Port);
    40.                     configureTcpSocket(socket);
    41.                     socket.Connect(ep);
    42.                     NativeHandler.NativeLog(3 + " :  done ");
    43.                 }
    44.                 catch (Exception ex)
    45.                 {
    46.                     NativeHandler.NativeLog(3 + " : " + ex.Message);//Protocol option not supported
    47.                 }
    48.             }
    49.  
    50.         private void configureTcpSocket(Socket socket)
    51.         {
    52.             try { socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true); }
    53.             catch { }
    54.             try { socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, true); }
    55.             catch { }
    56.             socket.ReceiveBufferSize = NetworkConfig.TcpReceiveBufferSize;
    57.             socket.SendBufferSize = NetworkConfig.TcpSendBufferSize;
    58.         }
    Tested on IPad (IOS 10.3.2) and iphone (IOS 11.1.2)
     
  16. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    I'm still a bit unclear about what is happening. I'm not sure which of the statements in the try blocks throws an exception. I'm also unsure about the string values used to parse the addresses. Do they need to be valid values?

    Maybe it is a better option to submit a bug report with a project that demonstrates the problem, then we can have all of the data about what is happening.
     
  17. sergienko88

    sergienko88

    Joined:
    Jul 22, 2013
    Posts:
    22
    I will planed it late.Need to deside this problem faster.But support answer so slow.
    So, now.I need to know what type of network using now (ip4/ip6/nat).Its real?

    IPHostEntry entry = Dns.GetHostEntry(hostNameOrAddress) always contains addresses ipv4 type on my host
     
  18. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    The type of network being used depends on the OS configuration. So if Dns.GetHostEntry always returns an IPv4 address, then the device where that code it running is on an IPv4 network.
     
  19. sergienko88

    sergienko88

    Joined:
    Jul 22, 2013
    Posts:
    22
    Tested on unity 2017.2.0f3 NAT64 network - Dns.GetHostEntry call exception - cant resolve host name. Good news : 3-4 monthes ago we sended to support our problem about IPv6 on IOS(can't connect no thi address type).They answer: this problem fixed on 2017.2.0p4 from 4 december. It's really works!But ... connect on address type ipv4 failed on NAT64
     
  20. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Ok, this does make sense. the NET64 network from a MacBook Pro is an IPv6-only network, so you cannot connect to an IPv4 address from it.
     
  21. unalone

    unalone

    Joined:
    Sep 3, 2013
    Posts:
    8
    But I'm using 2017.3, it still failed to resolve dns name under ipv6 environment using .Net 4.6 runtime!
     
  22. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    This sounds like a bug. Can you submit a bug report via the Unity editor for this issue?
     
  23. unalone

    unalone

    Joined:
    Sep 3, 2013
    Posts:
    8
  24. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Thanks for the bug report, we will investigate it. We had a similar issue that was corrected in 2018.1. The first 2018.1 beta will be out soon, so it might be worth trying this out there.

    Also, I don't think the current Mono runtime is impacted by this, so it might be worth switch off the experimental scripting runtime until we correct the issue.
     
  25. unalone

    unalone

    Joined:
    Sep 3, 2013
    Posts:
    8
    .Net 3.5 is SOOOOO OLD, and many features are missing, such as async/await.

    And, why you don't use the LLVM instead the Mono? I remember there are some .Net frontend for LLVM.
     
  26. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Please check out the experimental support for .NET 4.6 that is in Unity 2017.1 and later.

    I'm not aware of any .NET virtual machines implemented on LLVM. In any case, LLVM does not support all of the platforms Unity supports, and Mono is tracking the ever evolving .Net ecosystem really well, so we're likely going to stick with it.
     
  27. sergienko88

    sergienko88

    Joined:
    Jul 22, 2013
    Posts:
    22
    May be. But android connected without problems on address type ipv4 on nat64. It is so strange:confused:
     
  28. unalone

    unalone

    Joined:
    Sep 3, 2013
    Posts:
    8
    il2cpp may cause the binary size much bigger, so, why not just use LLVM as backend when targeting iOS/Android?

    And, that bug still exist so we cannot use .net 4.6 when targeting iOS platform.
     
  29. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Which bug are you referring to?
     
  30. unalone

    unalone

    Joined:
    Sep 3, 2013
    Posts:
    8
    DNS fail when targeting iOS platform using .net 4.6 runtime.
     
  31. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Ok, thanks. I did just fix a bug which sounds similar to this. It should be corrected in the next patch release or two of 2017.3.
     
  32. 479813005

    479813005

    Joined:
    Mar 18, 2015
    Posts:
    71
    unity2018.3.0b9
    IL2CPP
    .NET Standard2.0

    TcpListener.Create / TcpListener.Start / Socket.ConnectAsync don't work with IPV6.SocketException: Protocol option not supported.
    Code (CSharp):
    1. public async void TestIPV6()
    2.     {
    3.         const int Port = 55555;
    4.         var lister = new TcpListener(IPAddress.IPv6Loopback,Port);
    5.         lister.Start();
    6.         var task = lister.AcceptSocketAsync();
    7.  
    8.         var so = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
    9.         so.ConnectAsync(new IPEndPoint(IPAddress.IPv6Loopback, Port));
    10.  
    11.         if (await task is Socket socket)
    12.         {
    13.             Debug.Log(socket.Connected);
    14.         }
    15.     }
    PlayerConnection initialized from G:/Test/NetTest/BuildIL2CPP/NetTest_Data (debug = 0)
    PlayerConnection initialized network socket : 0.0.0.0 55333
    Multi-casting "[IP] 172.20.63.17 [Port] 55333 [Flags] 3 [Guid] 2948964965 [EditorId] 790993983 [Version] 1048832 [Id] WindowsPlayer(DESKTOP-GC9F3OM) [Debug] 1 [PackageName] WindowsPlayer" to [225.0.0.222:54997]...
    Waiting for connection from host on [0.0.0.0:55333]...
    PlayerConnection accepted from [172.20.63.17] handle:0x3d8
    Started listening to [0.0.0.0:55333]
    PlayerConnection already initialized - listening to [0.0.0.0:55333]
    Initialize engine version: 2018.3.0b9 (a3326ae325b2)
    GfxDevice: creating device client; threaded=1
    Direct3D:
    Version: Direct3D 11.0 [level 11.1]
    Renderer: NVIDIA GeForce GTX 1050 (ID=0x1c81)
    Vendor:
    VRAM: 1987 MB
    Driver: 23.21.13.8816
    WARNING: Shader Unsupported: 'HDRenderPipeline/Lit' - Pass 'META' has no vertex shader
    WARNING: Shader Unsupported: 'Hidden/HDRenderPipeline/TerrainLit_Basemap' - Pass 'META' has no vertex shader
    WARNING: Shader Unsupported: 'HDRenderPipeline/TerrainLit' - Pass 'META' has no vertex shader
    <RI> Initializing input.

    <RI> Input initialized.

    <RI> Initialized touch support.

    UnloadTime: 0.579700 ms
    Setting up 4 worker threads for Enlighten.
    Thread -> id: 5f28 -> priority: 1
    Thread -> id: 5bfc -> priority: 1
    Thread -> id: 61dc -> priority: 1
    Thread -> id: 4f4 -> priority: 1
    SocketException: Protocol option not supported
    at System.Net.Sockets.Socket.GetSocketOption (System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName) [0x00000] in <00000000000000000000000000000000>:0
    at System.Net.Sockets.Socket.get_DualMode () [0x00000] in <00000000000000000000000000000000>:0
    at System.Net.Sockets.Socket.get_IsDualMode () [0x00000] in <00000000000000000000000000000000>:0
    at System.Net.Sockets.Socket.RemapIPEndPoint (System.Net.IPEndPoint input) [0x00000] in <00000000000000000000000000000000>:0
    at System.Net.Sockets.Socket.Bind (System.Net.EndPoint localEP) [0x00000] in <00000000000000000000000000000000>:0
    at System.Net.Sockets.TcpListener.Start (System.Int32 backlog) [0x00000] in <00000000000000000000000000000000>:0
    at System.Net.Sockets.TcpListener.Start () [0x00000] in <00000000000000000000000000000000>:0
    at Login+<TestIPV6>d__8.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.Assertions.Assert.IsNull[T] (T value, System.String message) [0x00000] in <00000000000000000000000000000000>:0
    at Login.TestIPV6 () [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.Events.UnityAction.Invoke () [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.Events.InvokableCall.Invoke () [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.UI.Button.Press () [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1].Invoke (T1 handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.EventSystems.StandaloneInputModule.ProcessMousePress (UnityEngine.EventSystems.PointerInputModule+MouseButtonEventData data) [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent (System.Int32 id) [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent () [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.EventSystems.StandaloneInputModule.Process () [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.EventSystems.EventSystem.Update () [0x00000] in <00000000000000000000000000000000>:0
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0
    at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
    at System.Threading.SendOrPostCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.WaitForSeconds..ctor (System.Single seconds) [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.UnitySynchronizationContext.Exec () [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.UnitySynchronizationContext.ExecuteTasks () [0x00000] in <00000000000000000000000000000000>:0

    (Filename: currently not available on il2cpp Line: -1)
     

    Attached Files:

  33. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Can you submit a bug report? This is something we should correct.
     
  34. 479813005

    479813005

    Joined:
    Mar 18, 2015
    Posts:
    71
    JoshPeterson likes this.