Possible Problem BSD Sockets iOS15 on cellular

In our iOS app we have been using BSD sockets C Code for connecting to Server for 9 years now.

Recently we have seen a few reports of our App being unable to connect on the 5G/4G Cellular network.

First reports were from an iPhone 13 so I thought maybe this was a new issue with that model. But we have also seen it on iPhone 12 Pro Max.

The app works fine on Wifi but will not connect to the server on Cellular. This is only happening on some devices (not all devices)

Whilst trying to figure this out I have just discovered in the "networking overview" the statement "In iOS, using sockets directly using POSIX functions or CFSocket does not automatically activate the device’s cellular modem or on-demand VPN"

I was not aware of that but have seen no problems with Cellular since our App was launched 9 years ago.

I also see a post from Quinn the Eskimo saying that "On modern systems, however, the WWAN network is pretty much pinned up by various system services (most notably push notifications).

So has something changed with iOS15?

It will be a major rewrite if I have to move our networking protocol code away from BSD Sockets and in the meantime our customers will stop using our App.

Is it possible to get more certainty on this issue??

Could it just be a new iOS15 bug ?

Thanks

Dave

Answered by DTS Engineer in 694016022

So has something changed with iOS15?

I’m not aware of such a change. It’s more likely that there’s some other problem affecting your app. It’s hard to offer any insight with more concrete info.

This is only happening on some devices (not all devices)

Can you reproduce it with one of your devices?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

So has something changed with iOS15?

I’m not aware of such a change. It’s more likely that there’s some other problem affecting your app. It’s hard to offer any insight with more concrete info.

This is only happening on some devices (not all devices)

Can you reproduce it with one of your devices?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Any chance the issue correlates with enabling iCloud Private Relay? Take a look at a problem I have (link) which resembles yours in the broad strokes: old BSD socket code working perfectly for years before suddenly failing for a few “random” users on iOS 15. In my case the problem is the same on both Wi-Fi and cellular (as I had enabled Private Relay at the global level) but it’s worth a look.

Hey Scott.. Thanks... Yeah a few days I had already seen your Forum post with Eskimo about iCloud Frame Relay and I checked with customers and subsequently ruled it out as a cause of the problem.

This morning we actually discovered the real cause of our problem...

On one of our users experiencing the problem at the BSD socket level getaddrinfo was resolving to BOTH an IPv4 and IPv6 address. My code only ever tried to connect on iPv6 in that case. That failed to connect presumably because the cellular provider has some type of fault. They are newer 5G networks here in Europe.

I tried a new testflight version with customer this morning that will now try to connect to IPv4 instead if that happens and it fixed the problem!!!!

It was another forum item I saw from Eskimo

https://developer.apple.com/forums/thread/48996?answerId=146136022#146136022

which pointed me in this direction where he says "BSD Sockets requires you to call getaddrinfo and then write a loop over each returned address, opening and connecting the socket, until you get one that works. Doing that reasonably well requires some ugly code, code that can’t be as good as the OS’s implementation!!

That man Eskimo is a genius and saved me a ton of work!! I was close to starting a major rewrite of our App to use higher level networking code.

Thanks for your help

Possible Problem BSD Sockets iOS15 on cellular
 
 
Q