@@ -196,12 +196,21 @@ class Wippersnapper_ESP32 : public Wippersnapper {
196196 _mqtt_client_secure, WS._config .aio_url , WS._config .io_port , clientID,
197197 WS._config .aio_user , WS._config .aio_key );
198198 } else {
199- // Insecure connections require a NetworkClient object rather than a
200- // NetworkClientSecure object
201- _mqtt_client_insecure = new NetworkClient ();
202- WS._mqtt = new Adafruit_MQTT_Client (
203- _mqtt_client_insecure , WS._config .aio_url , WS._config .io_port ,
199+ if (WS. _config . io_port == 8883 ) {
200+ _mqtt_client_secure = new NetworkClientSecure ();
201+ _mqtt_client_secure-> setInsecure ();
202+ WS._mqtt = new Adafruit_MQTT_Client (
203+ _mqtt_client_secure , WS._config .aio_url , WS._config .io_port ,
204204 clientID, WS._config .aio_user , WS._config .aio_key );
205+ } else {
206+ // Insecure connections require a NetworkClient object rather than a
207+ // NetworkClientSecure object
208+ _mqtt_client_insecure = new NetworkClient ();
209+ WS._mqtt = new Adafruit_MQTT_Client (
210+ _mqtt_client_insecure, WS._config .aio_url , WS._config .io_port ,
211+ clientID, WS._config .aio_user , WS._config .aio_key );
212+ }
213+
205214 }
206215 }
207216
0 commit comments