mirror of https://github.com/arendst/Tasmota.git
MQTT now uses Tasmota's DNS resolver instead of LWIP (#17387)
This commit is contained in:
parent
0a57545e11
commit
ce0a0d05a9
|
@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file.
|
||||||
- ESP32 exception 28 when RtcNtpServer is enabled on restart (#17338)
|
- ESP32 exception 28 when RtcNtpServer is enabled on restart (#17338)
|
||||||
- Analog MQ exception 28 on restart (#17271)
|
- Analog MQ exception 28 on restart (#17271)
|
||||||
- ESP32 fix ``Ping``
|
- ESP32 fix ``Ping``
|
||||||
|
- MQTT now uses Tasmota's DNS resolver instead of LWIP
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|
|
@ -299,7 +299,7 @@ int WiFiClientSecure_light::connect(IPAddress ip, uint16_t port, int32_t timeout
|
||||||
setLastError(ERR_TCP_CONNECT);
|
setLastError(ERR_TCP_CONNECT);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return _connectSSL(nullptr);
|
return _connectSSL(_domain.isEmpty() ? nullptr : _domain.c_str());
|
||||||
}
|
}
|
||||||
#else // ESP32
|
#else // ESP32
|
||||||
int WiFiClientSecure_light::connect(IPAddress ip, uint16_t port) {
|
int WiFiClientSecure_light::connect(IPAddress ip, uint16_t port) {
|
||||||
|
|
|
@ -126,6 +126,10 @@ class WiFiClientSecure_light : public WiFiClient {
|
||||||
|
|
||||||
void setInsecure();
|
void setInsecure();
|
||||||
|
|
||||||
|
void setDomainName(const char * domain) {
|
||||||
|
_domain = domain;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _clear();
|
void _clear();
|
||||||
bool _ctx_present;
|
bool _ctx_present;
|
||||||
|
@ -172,6 +176,9 @@ class WiFiClientSecure_light : public WiFiClient {
|
||||||
// record the maximum use of ThunkStack for monitoring
|
// record the maximum use of ThunkStack for monitoring
|
||||||
size_t _max_thunkstack_use;
|
size_t _max_thunkstack_use;
|
||||||
|
|
||||||
|
// domain name (string) that will be used with SNI when the address provided is already resolved
|
||||||
|
String _domain;
|
||||||
|
|
||||||
// ALPN
|
// ALPN
|
||||||
const char ** _alpn_names;
|
const char ** _alpn_names;
|
||||||
size_t _alpn_num;
|
size_t _alpn_num;
|
||||||
|
|
|
@ -1065,11 +1065,12 @@ void MqttReconnect(void) {
|
||||||
MqttClient.setCallback(MqttDataHandler);
|
MqttClient.setCallback(MqttDataHandler);
|
||||||
|
|
||||||
// Keep using hostname to solve rc -4 issues
|
// Keep using hostname to solve rc -4 issues
|
||||||
if (!WifiDnsPresent(SettingsText(SET_MQTT_HOST))) {
|
IPAddress ip;
|
||||||
|
if (!WifiHostByName(SettingsText(SET_MQTT_HOST), ip)) {
|
||||||
MqttDisconnected(-5); // MQTT_DNS_DISCONNECTED
|
MqttDisconnected(-5); // MQTT_DNS_DISCONNECTED
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MqttClient.setServer(SettingsText(SET_MQTT_HOST), Settings->mqtt_port);
|
MqttClient.setServer(ip, Settings->mqtt_port);
|
||||||
|
|
||||||
if (2 == Mqtt.initial_connection_state) { // Executed once just after power on and wifi is connected
|
if (2 == Mqtt.initial_connection_state) { // Executed once just after power on and wifi is connected
|
||||||
Mqtt.initial_connection_state = 1;
|
Mqtt.initial_connection_state = 1;
|
||||||
|
@ -1085,9 +1086,11 @@ void MqttReconnect(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_MQTT_TLS
|
#ifdef USE_MQTT_TLS
|
||||||
|
|
||||||
uint32_t mqtt_connect_time = millis();
|
uint32_t mqtt_connect_time = millis();
|
||||||
if (Mqtt.mqtt_tls) {
|
if (Mqtt.mqtt_tls) {
|
||||||
tlsClient->stop();
|
tlsClient->stop();
|
||||||
|
tlsClient->setDomainName(SettingsText(SET_MQTT_HOST)); // set domain name for TLS SNI (selection of certificate based on domain name)
|
||||||
} else {
|
} else {
|
||||||
MqttClient.setClient(EspClient);
|
MqttClient.setClient(EspClient);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue