Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » Error handling when no PINGRESP received
Error handling when no PINGRESP received [message #1721105] Sat, 23 January 2016 21:37 Go to next message
Will Luke is currently offline Will LukeFriend
Messages: 2
Registered: January 2016
Junior Member
Hi,

I'm new to MQTT and loving it so far. But I'm trying to find out how to handle timeouts, particularly when a PINGRESP hasn't been received by a client.

I'm checking for a valid internet connection when the initial connection fails and essentially waiting until it becomes alive again. But if the remote broker fails or becomes unresponsive, how can I restart the connection from the beginning? Currently, the forever loop just waits to receive the PINGRESP (and waits forever)

I'm tinkering in Python at the mo. Thoughts welcome

Will

while True:
	try:
		mqttc.connect('cloudmqtt.com','16474')
# We should probably log this successful connection via mtqq in g, in a text file
# 		mqttc.publish("g/lamp", "ON")
		rc = 0
		while rc == 0:
			rc = mqttc.loop_forever(60,60,retry_first_connection=True)
		print("rc: " + str(rc))
	except socket.error:
#   Can't reach the server. We should check to see if the internet can be reached at all with a variety of pings
#   Also, colour the light red to indicate connection trouble		
		print "Connection trouble. Let's check to see if we can ping anything"
		
		if have_internet() is True:
			print "Internet connection is working. We'll sleep for 10 secs"
			time.sleep(10)
Re: Error handling when no PINGRESP received [message #1722228 is a reply to message #1721105] Wed, 03 February 2016 14:26 Go to previous message
Will Luke is currently offline Will LukeFriend
Messages: 2
Registered: January 2016
Junior Member
Any thoughts, anyone?
Previous Topic:Picking the latest paho JAR
Next Topic:where are the object files stored in the paho project
Goto Forum:
  


Current Time: Tue Apr 23 11:01:46 GMT 2024

Powered by FUDForum. Page generated in 0.02851 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top