You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The above code will wait a very long time to complete the last command.
I use a workaround to check availability:
local conn = socket.tcp_connect(mqtt_host, mqtt_port, 2)
if (conn ~= nil) then
conn:close()
mqtt_object = mqtt.new(mqtt_name, true)
local mqtt_status, mqtt_err = mqtt_object:connect({host=mqtt_host, port=mqtt_port})
...
else
error('Connect to host '..mqtt_host..' failed')
end
socket.tcp_connect will return nil if the port is unavailable after 2 seconds, thus anticipating a long wait. It would be nice if the MQTT library allowed you to set a timeout after which the connection is considered unsuccessful.
The text was updated successfully, but these errors were encountered:
If the server is not responding, but not refused connection, the library will wait a very long time.
Code:
The above code will wait a very long time to complete the last command.
I use a workaround to check availability:
socket.tcp_connect will return nil if the port is unavailable after 2 seconds, thus anticipating a long wait.
It would be nice if the MQTT library allowed you to set a timeout after which the connection is considered unsuccessful.
The text was updated successfully, but these errors were encountered: