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

Mosquitto 1.5.7: Socket error on client 'xxx', disconnecting. #1177

Closed
fmvin opened this issue Feb 22, 2019 · 9 comments
Closed

Mosquitto 1.5.7: Socket error on client 'xxx', disconnecting. #1177

fmvin opened this issue Feb 22, 2019 · 9 comments

Comments

@fmvin
Copy link

fmvin commented Feb 22, 2019

It looks like the same symptoms as described in #875, #872.

Reconnections repeat forever. This happens only if mosquitto and client are started from rc.local. If after system started up and the client is killed and started again manually from root session this problem is not repeated.
I get this issue on mosquitto 1.5.4 and 1.5.7 under linux 2.6.32

New client connected from 127.0.0.1 as mosq/ciKalXMsU4u=dlC_wb (c1, k3).
1550586971: No will message specified.
1550586971: Sending CONNACK to mosq/ciKalXMsU4u=dlC_wb (0, 0)
1550586971: Client mosq/ciKalXMsU4u=dlC_wb already connected, closing old connection.
1550586971: Socket error on client mosq/ciKalXMsU4u=dlC_wb, disconnecting.
1550586971: New client connected from 127.0.0.1 as mosq/ciKalXMsU4u=dlC_wb (c1, k3).
1550586971: No will message specified.
1550586971: Sending CONNACK to mosq/ciKalXMsU4u=dlC_wb (0, 0)
1550586971: New connection from 127.0.0.1 on port 1883.
1550586971: No will message specified.
1550586971: Received SUBSCRIBE from mosq/ciKalXMsU4u=dlC_wb
1550586971: Sending SUBACK to mosq/ciKalXMsU4u=dlC_wb
1550586971: Received SUBSCRIBE from mosq/ciKalXMsU4u=dlC_wb
1550586971: Sending SUBACK to mosq/ciKalXMsU4u=dlC_wb
1550586971: Received SUBSCRIBE from mosq/ciKalXMsU4u=dlC_wb
1550586971: Sending SUBACK to mosq/ciKalXMsU4u=dlC_wb
1550586971: Received SUBSCRIBE from mosq/ciKalXMsU4u=dlC_wb
1550586971: Sending SUBACK to mosq/ciKalXMsU4u=dlC_wb
1550586972: Client mosq/ciKalXMsU4u=dlC_wb already connected, closing old connection.
1550586972: Socket error on client mosq/ciKalXMsU4u=dlC_wb, disconnecting.
1550586972: New client connected from 127.0.0.1 as mosq/ciKalXMsU4u=dlC_wb (c1, k3).
1550586972: No will message specified.
1550586972: Sending CONNACK to mosq/ciKalXMsU4u=dlC_wb (0, 0)
1550586972: Received SUBSCRIBE from mosq/ciKalXMsU4u=dlC_wb
1550586972: Sending SUBACK to mosq/ciKalXMsU4u=dlC_wb
1550586972: Received SUBSCRIBE from mosq/ciKalXMsU4u=dlC_wb
1550586972: Sending SUBACK to mosq/ciKalXMsU4u=dlC_wb
1550586972: Received SUBSCRIBE from mosq/ciKalXMsU4u=dlC_wb
1550586972: Sending SUBACK to mosq/ciKalXMsU4u=dlC_wb
1550586972: Received SUBSCRIBE from mosq/ciKalXMsU4u=dlC_wb
1550586972: Sending SUBACK to mosq/ciKalXMsU4u=dlC_wb
1550586973: New connection from 127.0.0.1 on port 1883.
1550586973: Client mosq/ciKalXMsU4u=dlC_wb already connected, closing old connection.
1550586973: Socket error on client mosq/ciKalXMsU4u=dlC_wb, disconnecting.
1550586973: New client connected from 127.0.0.1 as mosq/ciKalXMsU4u=dlC_wb (c1, k3).
1550586973: No will message specified.
1550586973: Sending CONNACK to mosq/ciKalXMsU4u=dlC_wb (0, 0)
1550586973: No will message specified.
1550586973: Received SUBSCRIBE from mosq/ciKalXMsU4u=dlC_wb
1550586973: Sending SUBACK to mosq/ciKalXMsU4u=dlC_wb
1550586973: Received SUBSCRIBE from mosq/ciKalXMsU4u=dlC_wb
1550586973: Sending SUBACK to mosq/ciKalXMsU4u=dlC_wb
1550586973: Received SUBSCRIBE from mosq/ciKalXMsU4u=dlC_wb
1550586973: Sending SUBACK to mosq/ciKalXMsU4u=dlC_wb
1550586973: Received SUBSCRIBE from mosq/ciKalXMsU4u=dlC_wb
1550586973: Sending SUBACK to mosq/ciKalXMsU4u=dlC_wb
1550586974: New connection from 127.0.0.1 on port 1883.
1550586974: Client mosq/ciKalXMsU4u=dlC_wb already connected, closing old connection.
1550586974: Socket error on client mosq/ciKalXMsU4u=dlC_wb, disconnecting.
1550586974: New client connected from 127.0.0.1 as mosq/ciKalXMsU4u=dlC_wb (c1, k3).
1550586974: No will message specified.
1550586974: Sending CONNACK to mosq/ciKalXMsU4u=dlC_wb (0, 0)
1550586974: New connection from 127.0.0.1 on port 1883.
@fmvin
Copy link
Author

fmvin commented Feb 25, 2019

Please close this issue.

We found the root cause of the problem. We have 2 identical processes which are started from rc.local without any delay. It seems mosquitto generates a connection ID based on system time. So sometimes it's possible to get 2 identical "unique ID" for connection for different processes. We just add 1sec delay between these processes starting and problem goes away.

Hope it helps to someone else.

@ralight
Copy link
Contributor

ralight commented Feb 26, 2019

Thanks for reporting this, I'm sure it's a niggling problem for some.

This is actually in the client library, I've now used a finer resolution timer for the random client id generation there so this should be less likely to come up. Future versions of the library won't be generating the client ids themselves.

@ralight ralight closed this as completed Feb 26, 2019
@Kr4ntz
Copy link

Kr4ntz commented Apr 16, 2019

Hello, I am facing the same issue but I fail to figure out the cause, can you please help me?

1555427498: New connection from 10.10.10.118 on port 1883. 1555427498: Sending CONNACK to 10.10.10.118 (0, 5) 1555427498: Socket error on client <unknown>, disconnecting. 1555427513: New connection from 10.10.10.118 on port 1883. 1555427513: Sending CONNACK to 10.10.10.118 (0, 5) 1555427513: Socket error on client <unknown>, disconnecting. 1555427528: New connection from 10.10.10.118 on port 1883. 1555427528: Sending CONNACK to 10.10.10.118 (0, 5) 1555427528: Socket error on client <unknown>, disconnecting. 1555427543: New connection from 10.10.10.118 on port 1883. 1555427543: Sending CONNACK to 10.10.10.118 (0, 5) 1555427543: Socket error on client <unknown>, disconnecting. 1555427558: New connection from 10.10.10.118 on port 1883. 1555427558: Sending CONNACK to 10.10.10.118 (0, 5)

This message repeats to eternity.

@ralight
Copy link
Contributor

ralight commented Apr 17, 2019

Sending CONNACK to 10.10.10.118 (0, 5)

The 5 here is the code for not authorised. Are you providing the correct username/password?

@Kr4ntz
Copy link

Kr4ntz commented Apr 18, 2019

Sending CONNACK to 10.10.10.118 (0, 5)

The 5 here is the code for not authorised. Are you providing the correct username/password?

I am terribly sorry, we assumed users and passwords were right - Indeed, there was an error in a password. Thanks for your time to reply.

@cjmaynard
Copy link

Perhaps it would be more helpful to print human readable return code messages rather than numeric codes alone, e.g., "not authorised" instead of "5"? I realize the return codes are documented in the MQTT specification, but here it's not quite obvious that the 2nd value in the parenthesis refers to the reason code, and even if were obvious, unless one has all the codes memorized, it still requires a lookup either in the source code or the documentation to find out the meaning of the code.

@joelgamal
Copy link

can you please provide me with steps to solve this problem?

@jetdom
Copy link

jetdom commented Aug 30, 2019

We just add 1sec delay between these processes starting and problem goes away.

How did you do this?

@satreddys
Copy link

satreddys commented Sep 24, 2019

We just add 1sec delay between these processes starting and problem goes away.

Can someone explain how to do this?

@lock lock bot locked as resolved and limited conversation to collaborators Dec 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants