Connection drops after ~1 minute

23 views
Skip to first unread message

m...@darrennix.com

unread,
Feb 7, 2015, 6:18:03 PM2/7/15
to lel...@googlegroups.com
I got my project up and running on my Raspberry Pi by following http://lelylan.github.io/lab-projects/raspberry-pi-light/.

However, I've noticed that the client loop consistently drops after ~1 minute, causing the project to exit with code 7.

I solved the problem by retrying the connection after it drops.  However, I'd like to understand if the timeout is by design and also discuss a more robust keepalive/retry approach.

# Retry client loop if connection drops

def maintain_connection():

    # client connection

    client.username_pw_set(device_id, device_secret)  # MQTT server credentials

    client.connect('178.62.108.47')                   # MQTT server address

    client.subscribe(in_topic, 0)                     # MQTT subscribtion (with QoS level 0)


    # Continue the network loop, exit when an error occurs

    rc = 0

    while rc == 0:

        rc = client.loop()

    print('rc: ' + str(rc))

    time.sleep(2)

    maintain_connection()

 

Lelylan Touch

unread,
Feb 12, 2015, 5:33:18 AM2/12/15
to lel...@googlegroups.com
Hi Darren, 

sorry for the delay on our answer. It's really strange the fact that the connection is ending up after one minute. It's not a design approach and we didn't got such a problem when we tested out the Raspberry Pi. 

I'll be happy to discuss more about what can be done to solve the problem, as it kind of looks like a bug to us.
Thanks a lot

--
You received this message because you are subscribed to the Google Groups "Lelylan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lelylan+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Andrea Reginato
Lelylan, Building the Connected Home
http://lelylan.com
Reply all
Reply to author
Forward
0 new messages