TcpClient.Connect() on iOS 14 triggers local network access permissions required

Hi, I’m having an issues on iOS 14 with calls to TcpClient client = new TcpClient("some.remote.host.com", 10161) is causing a local network permission requirement that reads "App ... would like to find and connect to devices on your local network".

If the user select “Don't allow” network access is denied and the app can not connect to our remote server.

I’ve tested this on both Unity 2019.2.12f1 and 2020.1.11f1 with Xcode 12.1 (12A7403) with the same result on each.

I was suspicious that it could have been caused by hitting the local DNS server (on local network) but performing a manual IPAddress[] serverIPs = Dns.GetHostAddresses(url); succeeds without issue and calling TcpClient.connect(...) with the returned IP address failed with the same issue.

I understand that iOS 14 has new privacy requirements and permissions are required to access machines on the local network but this should not fall into that category as we’re only connecting to remote hosts.

This is a total show stopper for our networked games.

Any ideas?

Anyone else having this issue?

I’m totally stumped here - any Unity support able to look into this?

Note, I’ve done more testing and it appears to occur when we use the port number 10161 that our server is listening on. Connecting to port 80 does not trigger this network permission requirement.

Very frustrating.

This code will trigger the Local Network Access permissions on iOS 14:

            IPAddress address = IPAddress.Parse(<add remote ip address here>);
            IPEndPoint endPoint = new IPEndPoint(address, 10161);
            client = new TcpClient();
            client.Connect(endPoint);

Did you open a bug report for this?

Now that I read the post, We have been experiencing connectivity issues with CloudKit with some betatesters, the error on the exceptions was CKCode 3 which means network not available, even when that user had 4G .
Im wondering now if this could be the case.

Indeed, unless the user selects to allow local network access we get a “No Route To Host” error.

Yep.

I’m trying to correlate it with a bug I’ve found so if you don’t mind… Does it happen both connected to wifi and using 3g/4g ?
Which iOS version is happening with ? 4.0 , 4.0.1 , 4.2 ?

Thank you very much, please keep us updated about this

I don’t have any SIM in my test device so I’ve only tested on wifi. Can not comment on 3g/4g.

I’ve confirmed this is an issue on both iOS 14.1 and 14.2.

Okay thanks, it seems is not the same bug then.
Still if you could update us about what you find it would be great.

Just in case anyone is interested, we’ve solved this issue.

The issue is that that port (10161) is reserved for SNMP over TLS and due to this was included in the list of criteria that will flag local network access.

This has been confirmed by Apple and they’ve indicated that after investigating further they intend on removing this restriction in a later version of iOS (it’s not yet in any seeded release).

I gotta say, feeling rather unlucky to be allocated one of the very few ports of the 65535 we could have been allocated that caused this issue!

1 Like

Hi! I’m also struggling with this error. Do you maybe have a full example of the code? I’m getting a lot of errors when I try to import this.

You’ll need to replace the <add remote ip address here> with an actual address.