Hi @Guillermo-Schimmel,
I know it's closed but just noticed this issue, you most probably had STP (Spanning Tree Protocol) enabled on that port, which is normal for ent switch, and while it waits for a loop it blocks trafic from that port.
Disabling that feature should solve this problem.
linkinpio
@linkinpio
Best posts made by linkinpio
- 
    RE: [SOLVED] Ethernet MQTT Gateway Slow to connectposted in Troubleshooting
Latest posts made by linkinpio
- 
    RE: 💬 Building a MQTT Gatewayposted in AnnouncementsI think I'm ussing the latest one 
  
 but as you said I don't think it will fix my issue though.
 But looking at the examples I found that they have a connect function which then can be used to reconnect whenever needed not constantly like it happens now,But not sure how I could integrate that functionality in this sketch though, as I'm not that experienced with programming  
 To you think it will be possible?/* Reconnecting MQTT example - non-blocking This sketch demonstrates how to keep the client connected using a non-blocking reconnect function. If the client loses its connection, it attempts to reconnect every 5 seconds without blocking the main loop. */ #include <SPI.h> #include <Ethernet.h> #include <PubSubClient.h> // Update these with values suitable for your hardware/network. byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED }; IPAddress ip(172, 16, 0, 100); IPAddress server(172, 16, 0, 2); void callback(char* topic, byte* payload, unsigned int length) { // handle message arrived } EthernetClient ethClient; PubSubClient client(ethClient); long lastReconnectAttempt = 0; boolean reconnect() { if (client.connect("arduinoClient")) { // Once connected, publish an announcement... client.publish("outTopic","hello world"); // ... and resubscribe client.subscribe("inTopic"); } return client.connected(); } void setup() { client.setServer(server, 1883); client.setCallback(callback); Ethernet.begin(mac, ip); delay(1500); lastReconnectAttempt = 0; } void loop() { if (!client.connected()) { long now = millis(); if (now - lastReconnectAttempt > 5000) { lastReconnectAttempt = now; // Attempt to reconnect if (reconnect()) { lastReconnectAttempt = 0; } } } else { // Client connected client.loop(); } }
- 
    RE: 💬 Building a MQTT Gatewayposted in Announcements@electrik 
 tried it but also no luckC:\Users\p.\Documents\Arduino\GatewayW5x00MQTTClient\GatewayW5x00MQTTClient.ino: In function 'void setup()': C:\Users\p.\Documents\Arduino\GatewayW5x00MQTTClient\GatewayW5x00MQTTClient.ino:213:10: error: 'class PubSubClient' has no member named 'setSocketTimeout' client.setSocketTimeout(1); ^~~~~~~~~~~~~~~~ exit status 1 Compilation error: 'class PubSubClient' has no member named 'setSocketTimeout'```
- 
    RE: 💬 Building a MQTT Gatewayposted in Announcements@electrik I've put the #define MQTT_SOCKET_TIMEOUT 1in the beginning where all other #defined constants are and it does not seeams to take this config. 
 I tried to usesetSocketTimeout(1)but I can't seems to get the sketch to work with <PubSubClient.h> 
 I've addedEthernetClient ethClient; PubSubClient client(ethClient); client.setSocketTimeout(1);but getting following error. GatewayW5x00MQTTClient.ino:172:1: error: 'client' does not name a type client.setSocketTimeout(1); ^~~~~~ exit status 1 Compilation error: 'client' does not name a typeany ideas? 
- 
    RE: 💬 Building a MQTT Gatewayposted in Announcements@electrik 
 Have you tested this in your enviroment/sketch?
 Did it increase availability for your sketch?
 If yes what was the single loop time before and after changing this?
 I did test is on my example and it does not increase the availability for the main loop for my sketch, also you can see the printout from the serial monitor, the loop is run in the same 3s intervals like before, so maybe I am doing something wrong?
- 
    RE: 💬 Building a MQTT Gatewayposted in Announcements@electrik thank you for your suggestion, but are you talking about MQTT_SOCKET_TIMEOUT ? 
 If yes I did set this to 1s#define MQTT_SOCKET_TIMEOUT 1and did not change a thing 21:32:05.081 -> Loop count = 153 21:32:05.081 -> 471258 GWT:TPC:IP=192.168.11.111 21:32:06.098 -> 472262 GWT:RMQ:CONNECTING... 21:32:08.071 -> 474266 !GWT:RMQ:FAIL 21:32:08.071 -> Loop count = 154If not please do let me know what you had in mind so I can check it out. @OldSurferDude thanks for confirming that I have not missed anything when doing a resarch on this matter, if there will be no new suggestions I think I might have to post it to Development as dont see anyone suggesting any good workaround or a solution. 
- 
    RE: [SOLVED] Ethernet MQTT Gateway Slow to connectposted in TroubleshootingHi @Guillermo-Schimmel, 
 I know it's closed but just noticed this issue, you most probably had STP (Spanning Tree Protocol) enabled on that port, which is normal for ent switch, and while it waits for a loop it blocks trafic from that port.
 Disabling that feature should solve this problem.
- 
    RE: 💬 Building a MQTT Gatewayposted in AnnouncementsHello, 
 I'm new here so sorry if this is not the right place for this question.
 But I am trying to build Arduino MQTT GW to act as a relay/light controller and report/interact with HomeAssistant.
 I think I have worked out most of my problems and got it running as I wanted to, but I was testing failover senarios as the controller should be able to work independently of any other device as long it has power.
 My config is kind of simple Arduino Mega with W5500 Ethernet module configured as MQTT GW
 And the problem is that when network or HA/MQTT broker is unavailable when Arduino is restarted/booting it tries to reconnect to MQTT broker constantly and interupts the main loop everytime for around 3s which makes board basically unresponsive.00:45:07.094 -> 549536 !GWT:RMQ:FAIL 
 00:45:07.094 -> Loop count = 179
 00:45:07.094 -> 549538 GWT:TPC:IP=192.168.11.111
 00:45:08.107 -> 550542 GWT:RMQ:CONNECTING...
 00:45:10.130 -> 552547 !GWT:RMQ:FAIL
 00:45:10.130 -> Loop count = 180
 00:45:10.130 -> 552550 GWT:TPC:IP=192.168.11.111Any ideas how I could disable reconnect function if that happens for example after 3 attempts? So the controller can work normally even if there is no connection to MQTT broker?