Open annadierothe opened 2 years ago
const char* mqttServer = "eduroam"; <----- you cant name it like that it must be IP number or you must create a dns .
char _tpm[3]; sprintf(_tpm, "Simon%06u", ESP.getChipId()); if(WiFi.status() == WL_CONNECTED){ if(MDNS.begin(_tpm)){ //Start mDNS with name esp8266 ////Serial.println("MDNS started"); MDNS.addService("http", "tcp", 80); ////Serial.println("MDNS Service Started"); MDNS.update(); } }
WiFi.begin();
Hello, I have a similar problem as a lot of people here, however the fixes did not work for me until now. I use an ESP32 with platformio and I connect it to the eduroam network. Whenever I try to connect, the wifi connection does work, however the MQTT connection fails with the code -2 (More precisely Attempting MQTT connection [720604][E][WiFiClientSecure.cpp:135] connect(): start_ssl_client: -1 Trying connect again -2)
!!!The code worked before but I had to update platformio, so I went into the error, that esp_wpa2_config_t is undefined. I could solve that problem by reducing the following code: esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT(); if (esp_wifi_sta_wpa2_ent_enable(&config) != ESP_OK) { Serial.println("WPA2 Settings Not OK"); } to this code: if (esp_wifi_sta_wpa2_ent_enable() != ESP_OK) { Serial.println("WPA2 Settings Not OK"); } I am not sure whether this can be also the reason, that is why I mentioned it, however the Wificonnection works successfully with following (and code throws same error if it is connected to local network):
What I tried so far: I used before only WiFiClient, that ended up with state -4, WiFiClientSecure ends with state -2; I changed the MQTT_MAX_PACKET_SIZE to 1024 and 2048, did not change anything, I tried Port 1883, also did not help. Password and username are corrected, I have also a Python code which runs successfully and as I mentioned, this code also worked before.
I would be really happy if somebody could help!
The following is my code:
and in my main file: