user1770223
user1770223

Reputation: 1

iOS App - Runs great on first install, poor network subsequent runs, restarting 4 times in a row "fixes" it (until next time)

I made a mobile app using Flutter. This app is data heavy (API and map tiles).

It always works on Android, iOS simulators, and Windows.

But on a physical iOS device, (both release and debug modes), same story:

Error: SocketException: Failed host lookup: 'site.com' (OS Error: nodename nor servname provided, or not known, errno = 8) 

Error: SocketException: Connection failed (OS Error: Too many open files, errno = 24), address = site.com, port = 443 

The above errors come in the hundreds, since they are related to map tiles. However, earlier http requests (about 10) to the same "site.com" (API/JSON) do not fail. All the same, I did a network check at a top level of the app and printed out the success for the same "site" that it claims "Failed host lookup" for.

Why does everything work smoothy on first install, but on subsequent runs, network requests fail and/or too many open files?

What does closing and re-opening the app 4 times in a row "do" iOS-wise that consistently fixes the problem (for the session)?

I thought also it may have to do with IPv4/IPv6. On the devices that work, I have DNS set to automatic/router, while the problem device was using 1.1.1.1 and 1.0.0.1.

When I switch the device to LTE on iphone 11, suddenly it worked great! No missing requests each time I opened and closed the app for several times in a row. Then today, erratic behavior again. On my iphone 15, I get missing tiles/requests on 5G as well. In all cases, restarting app 4 times seems to reset something so it all works again.

I also printed the IP string in my app to see if any difference. Using Wifi, it was IPv4 and when LTE, it was IPv6. Same strange behavior either way.

The only CONSISTENT thing is that Android, and iOS simulators on my new Mac never have an issue. Just physical iphones.

UPDATE: This thread closely mimics what I am experiencing.

Upvotes: -1

Views: 168

Answers (1)

user1770223
user1770223

Reputation: 1

FIXED.

I installed native_dio_adapter to go along with dio, which flutter_map package uses.

Now no file limit errors. In addition, network requests are noticeably faster.

Upvotes: 0

Related Questions