Esp32: wifi connect results in auth failed

When connecting to the wifi i frequently get an 201 Auth failed error. I traced this back and found that the issue started with version 0.12

The error appears when i start of the code of my RobustWifiServer (arduinolibs/wifi at master · gmoehler/arduinolibs · GitHub), which is a try to create a wifi server that reconnects when issues appear using a state approach (side remark: comments on that piece of code is highly appreciated btw).

Server startup behind the scenes should be nothing else than

[in setup]
_server = WiFiServer(serverPort);
[in loop]
WiFi.mode(WIFI_STA);                  // "station" mode
WiFi.config(_ip, _gateway, _subnet);  // set specific ip...
WiFi.begin(_ssid.c_str(), _wifiPassword.c_str());     // connect to router

I usually do a --port COM4 erase_flash before program upload to be on the save side. Sometimes i have to repeat the erase_flase - upload cycle twice before i run into the issue.

When i start up the server what i get in 0.12.0 onward is:

Connecting to Wifi with SSID MY_SSID7 & ip
>> Wifi Event: Wifi ready.
>> Wifi Event: AP stop
>> Wifi Event: Wifi started...
>> Wifi Event: Wifi started...
>> Wifi Event: WiFi lost connection.
Reason: 201 - AUTH_FAIL

The wifi state turns from WL_DISCONNECTED to WL_NO_SSID_AVAIL due to an auth fail event. Any following connection tries will not even try to connect and hang in WL_NO_SSID_AVAIL state (although the SSID scan finds the router). versions connection 0.11.1 and earlier connect just fine (server starts and waits for clients).

Does anyone have a clue what could go wrong. If the code is too complicated to follow i could minimize it to to a snippet that illustrates the problem.

BTW there is some similarity to the issue ESP32 issues connecting Wifi network - #2 by ivankravets, but the hints there did not help.

I solved the issue by moving to the native (IDF) instead of using the Arduino WiFi functions.