Unable to join Wifi for the first time using NEHotSpotConfiguration

My iOS app needs to connect to an IOT device Wi-Fi, which does not have internet access.

iOS app already knows the ssid password of the iOT device Wi-Fi.


So I tried connecting to IOT device Wi-Fi using [NEHotspotConfigurationManager applyConfiguration] API.

The issue is that my app fails to join IOT device Wi-Fi in the first attempt. It connects on second attempt.

I have verified that IOT wifi was enabled and availble in Wi-Fi list in Settings > Wi-Fi


In code, error in applyConfiguration callback is nil, indicating success, so I check for connected Wi-FI SSID using CNCopyCurrentNetworkInfo

As SSID is different (other network) from my IOT device Wi-Fi SSID, it implies that iPhone is still connected to previosly connected Wi-Fi.


At around the same point, iOS shows the system dialog "Unable to connect to Wifi".

I checked for error in system logs while attempting connection, and found that the "wifid" process logs

"__WiFiDeviceManagerForcedAssociationCallback: failed to association error 2" for com.apple.SystemConfiguration subsystem



I tried this couple of times, and got this error in console logs everytime connection attempt failed.

App is able to connect on subsequent attempts.


Any help would be very much appreciated if someone has experienced the same.


Thank you

This is a good move in determining if the iOS device has completely associated with the IoT network. I would continue to check the SSID of the associated network before continuing on with your network task. If you are using NSURLSession to communicate with your IoT device then I would also encourage you to use waitsForConnectivity on the NSURLSessionConfiguration to ensure the network is fully available before the task is used.

| As SSID is different (other network) from my IOT device Wi-Fi SSID, it implies that

| iPhone is still connected to previosly connected Wi-Fi.



Interesting. Another test I would try is forgetting all previously saved Wi-Fi networks on your iOS device settings. Also make sure you are out of range of a previously used Wi-Fi signals. Test the connection again to see if this makes a difference in association. I would also tail the system logs of your IoT device while you are making the connection. Just to see if this provides you further information.

| At around the same point, iOS shows the system dialog "Unable to connect to Wifi".

| I checked for error in system logs while attempting connection, and found that the

| "wifid" process logs

| "__WiFiDeviceManagerForcedAssociationCallback: failed to association error 2" for

| com.apple.SystemConfiguration subsystem


This should be captured in a bug report with this information provided. Please open one here and reply back with the bug number.



Matt Eaton

DTS Engineering, CoreOS

meaton3 at apple.com

Thanks for the quick response Matt !


I did few rounds of testing as you suggested, forgetting all saved Wi-Fi networks on the iOS device. I also tested by switching off device Wi-Fi at the beginning of this process, so that Wi-Fi gets turned On only when app request connection.

It doesn't look like there is any impact of these changes on the issue, as i was still getting connection error on several occasions. (intermittently)


One thing I noticed was that error logs in system console, showed "__WiFiDeviceManagerForcedAssociationCallback: failed to association error 1" instead of error 2 a few times.


I have filed a bug with all this information - FB7612833


Regards,

Srijan

Srijan,


No problem and thank you for filing a bug. I took a look at the associated sysdiagnose and I noticed a few things; first I see that you have at least one VPN connection being used throughout the lifespan of your logarchive. Try to disable the VPN completely and retry the tests above. Your VPN looked like it was cycling back an forth between connecting and disconnecting and I want to rule this out as a possible issue in the link connection to your IoT device. Second, can you add the SSID name of the network you are trying to connect to on the bug (not here), so I can better scan the WiFiManager log?



Matt Eaton

DTS Engineering, CoreOS

meaton3 at apple.com

Hey Matt !

I'm not sure how a VPN connection is being shown in logs. My iOS device is not using VPN (or any VPN apps) or has any saved VPN configuration.

I've updated the details in the bug.



Regards,

Srijan

Unable to join Wifi for the first time using NEHotSpotConfiguration
 
 
Q