Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSError: [Errno 104] ECONNRESET #174

Open
jonascasarin opened this issue May 4, 2017 · 4 comments
Open

OSError: [Errno 104] ECONNRESET #174

jonascasarin opened this issue May 4, 2017 · 4 comments

Comments

@jonascasarin
Copy link

Hey, I've a question about connect method in umqtt lib: In the first time connection, even using robust mqtt, my broker need be on-line. If my server is Down at the moment return this error:

Traceback (most recent call last):
File "umqtt/simple.py", line 56, in connect
OSError: [Errno 104] ECONNRESET

If my broker is on-line at first connection, and after i put down my server, it keeps working well (trying reconnect).

So, can I treat this error for dont stop my application, or it's a problem in the lib?

@garybake
Copy link

garybake commented May 4, 2017

Not sure if this is any help - a comment in some example code

    # A port on which a socket listened remains inactive during some time.
    # This means that if you run this sample, terminate it, and run again
    # you will likely get an error. To avoid this timeout, set SO_REUSEADDR
    # socket option.
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

@jonascasarin
Copy link
Author

jonascasarin commented May 4, 2017

Do u mean to change this in the lib?!...
Cause there is nothing like that...
And my basic code is junting subscribing in some topics and i tried used setsockopt in client (mqtt object) and doesnt work.

Just to understand my simple aplication:

def mqtt():
    global client 
    client = MQTTClient(CONFIG['client_id'], CONFIG['broker'], CONFIG['port'], CONFIG['username'], CONFIG['password'])
    client.DEBUG = True
    client.set_callback(sub_cb)
    client.settimeout = settimeout
    if not client.connect(clean_session=False):
        client.subscribe(b"sensor/{}/{}".format(CONFIG['usercode'],CONFIG['client_id']))
        print("Connected to {}".format(CONFIG['broker']))
    while 1:
        client.check_msg()
        time.sleep(1)

If could I treat this error in my application would be better than change something in the lib...u dont think so?!... couldn't stop an aplication because this.

I'll seize to ask if when reconect in my broker it's possible subscribe in topic... because I was noticed that when mqtt client is down (offline) and active reconect mode, block all aplication (including whiles and so on).

@garybake
Copy link

garybake commented May 5, 2017

Apologies, I hadn't read it properly and rushed to reply. My original comment is no help and should be ignored.

@jonnor
Copy link

jonnor commented Aug 25, 2024

Is this still a problem in the latest version of mqtt.simple ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants