iOS 14.2, NEHotspotConfiguration connection issue.

When I connect to the IoT device, from my app (NEHotspotConfiguration API, iOS 14.2), sometimes the wifi connection takes a few minutes. On iOS 12.3 it works well. This issue is reproducible once every 5 test connections.

Environment
  1. IoT device (esp32) doesn't have an internet connection

  2. HTTP server is run on IoT devices.

Steps to reproduce:
  1. Call NEHotspotConfigurationManager.shared.apply. SSID, Passphrase, isWEP=false, joinOnce=false. Connection response without error

  2. Wait 10 seconds, send HTTP request from the app to the device.

Result
  1. HTTP request is failed. NSURLErrorNotConnectedToInternet error code.

  2. On the wifi settings screen I see: "progress indicator" near the IoT device's Wi-Fi and "No internet connection" message. When I tap on Wi-Fi to open the detail screen, I see an incorrect IP address.

  3. If I try to send an HTTP request from Safari to my device, I see no internet connection message too.

Look like it still trying to connect to the device.

But, If I wait a few minutes when the progress indicator and "No internet connection" message disappear (iOS settings screen):
  1. IP address now is correct

  2. Safari display success response from the device

  3. Mobile receives a successful response without any errors.

joinOnce=true, joinOnce=false works the same. You need to wait for a few minutes to have a connection with device.
Tested on iPhone8(iOS 14.2, iOS14.3), iPhoneX(iOS 14.2),

Replies

Update
Reproduced the same case without application. Just switch in iOS wifi settings between Home Wifi and Device wifi. Once per 5 switches, Device Wifi display a message as on screenshot and connecting need more than 2 minutes, in other cases immediately (4 seconds)
Sounds like DHCP is having an issue handing out an IP, and then getting the association established. This would be the first thing I would check, to see if there is any logging on your device to review why handing out an IP is not going as expected. You could also take a sysdiagnose with the Wi-Fi logging profile installed on iOS and take a look at the Wi-Fi manager log for more clues.

From the iOS app side of things, try using waitsForConnectivity on NSURLSessionConfiguration to make sure the session is completely ready before the HTTP request goes out.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Hello Matt Eaton
Thanks for your advice. I have reproduced this issue without my IoT device, switched between 2 office routers (from iPhone settings app, my app was removed). The result was the same, sometimes the connection needs 2 minutes to get an IP address. I have run a wifi profile on iOS, and see the same delay. This is info from the profile:

Code Block
12:23:56.694 Attempting to join WPA network: XXXXXXXX
12:23:57.041 WiFiLQAMgrSetCurrentNetwork: Joined SSID: XXXXXXXX BSSID: xx:xx:xx:xx:xx:xx RSSI: -32 Chan: 6 ApEnv: Learning(1)
RSSI: -32 Chan: 6 ApEnv: Learning(1)
12:26:05.752 {AUTOJOIN-} WiFiDeviceManagerRouterIpv4Callback: ip address configuration completed for XXXXXXXX


Reboot device or reset networking settings helps for the first few hours, then the issue is reproducible again.

Use waitsForConnectivity, in this case, is not a good solution, because 2 minutes is too much for waiting. I can't reproduce this issue on iPhoneXMax (iOS 14.2).

The result was the same, sometimes the connection needs 2 minutes to get an IP address. I have run a wifi profile on iOS, and see the same delay. This is info from the profile:

Having to wait 2 minutes for your device to get an IP address is not normal. In your WiFiManager log do you have see a 2 minute delay for the device to get an IP? If so, is there any other logs that indicate an issue during this time?

Use waitsForConnectivity, in this case, is not a good solution, because 2 minutes is too much for waiting. I can't reproduce this issue on iPhoneXMax (iOS 14.2).

Yeah, if your device is waiting 2 minutes to get an IP then this is not a good solution. If you continue to have issues here then open up a TSI and I can dig into your sysdiagnose to see if there's anything there I can uncover.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Our team also faces this issue on different devices and different iOS 14.x versions using both NEHotspotConfiguration API and iOS Setting without the app.

After connection to Wi-Fi, getting IP address takes about 2 minutes.

VictorVV, have you created a TSI ticket and received any feedback on this issue?
vadzimfrombelin I have created a TSI ticket only today. Feb 01. 2020. Didn't have time to do it before.
Thanks ViktorVV,

Could you let us know if there is any outcome from TSI ticket?
This looks a lot like a feedback assistant issue i created, but unfortunately was closed by Apple: FB8903217.

The issue i am facing is that iOS sends the wrong MAC address in the DHCP Discover packet.
It sends the private MAC from the previous WiFi connection to the new WiFi connection. Thereby leaking the previous private MAC address to the new WiFi network!

The router correctly responds with a DHCP Offer with the same (wrong) MAC address in it. iOS ignores this, since it is not the correct MAC for this WiFi network.
After around 130s iOS starts sending the correct MAC address in the DHCP Discover packet and then immediately the WiFi connection succeeds.

This causes a very long delay for the end-user to connect to a WiFi network which is not acceptable.
It is also a security issue since it exposes the private MAC to the wrong WiFi network

I provided logging and tcp-dumps but unfortunately it was just closed by Apple without further explanation.
Hello vadzimfrombelin 

DTS closed the TSI ticket.

Code Block
Thank you for contacting Apple Developer Technical Support (DTS). We provide fee based development-level technical support to software developers. We do not provide user-level assistance for Apple products.
For support options including help with installing, using or updating Apple Software or help obtaining support or service for your Apple device, please refer to the support options listed at <https://support.apple.com/contact>.

@VictorVl

Was there a specific code level question that was asked here or did you end up getting your issue resolved?


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com

This looks a lot like a feedback assistant issue i created, but unfortunately was closed by Apple: FB8903217.

The issue i am facing is that iOS sends the wrong MAC address in the DHCP Discover packet. It sends the private MAC from the previous WiFi connection to the new WiFi connection. Thereby leaking the previous private MAC address to the new WiFi network!

The router correctly responds with a DHCP Offer with the same (wrong) MAC address in it. iOS ignores this, since it is not the correct MAC for this WiFi network. After around 130s iOS starts sending the correct MAC address in the DHCP Discover packet and then immediately the WiFi connection succeeds.This causes a very long delay for the end-user to connect to a WiFi network which is not acceptable.
It is also a security issue since it exposes the private MAC to the wrong WiFi network
I provided logging and tcp-dumps but unfortunately it was just closed by Apple without further explanation.

@TeunVR 
Yes!!! We meet the same question.

@meaton
This is the cause of the problem

Hello Mr Matt Eaton

@meaton



Ethernet II, Src: fe:49:cd:a5:94:bd

Client MAC address: da:42:c4:5a:60:d1



"fe:49:cd:a5:94:bd" is the right mac address (private mac address) of current connection (the new one)
but "Client MAC address: da:42:c4:5a:60:d1" is the wrong mac address (private mac address) of previous connection

@meaton

Was there a specific code level question that was asked here or did you end up getting your issue resolved?

No, I didn’t resolve this issue. I didn’t provide code in the ticket, because reproduced the same issue without my application. 
I opened iOS native settings app and start switching between 2 companies Wifi AP, sometimes WIFI connection stuck for 2 minutes. So I think it is an iOS issue.

I don’t know why but if you disconnect from the freeze Wifi AP and connect one more time, the second connection is fast. But then if you continue switching between network issue reproduces again