Skip to content
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.

Problem connecting to surgemq #51

Open
chessweb01 opened this issue Apr 4, 2017 · 2 comments
Open

Problem connecting to surgemq #51

chessweb01 opened this issue Apr 4, 2017 · 2 comments

Comments

@chessweb01
Copy link

chessweb01 commented Apr 4, 2017

I'm running an MQTT client that is able to connect to the public MQTT brokers at broker.mqtt-dashboard.com and iot.eclipse.org, but when I try to connect the client to a stand-alone surgemq broker running on my own machine it fails.

The broker runs without error messages, so I guess it is listening for connections. My client however, cannot connect.

Does anyone have an idea what might be wrong with my setup?

@chessweb01
Copy link
Author

Figured it out:
I checked the CONNACK return code from the broker and found that it was 0x02 which means the broker rejects the client ID. The rejection is due to the regular expression against which the client ID is checked (see file surgemq/message/connect.go). It is ^[0-9a-zA-Z _]*$ which means that a client ID containing hyphens (-) will not be accepted.

Once I picked a client ID without hyphens the client connected without further issues. I wonder if there is a reason for rejecting hyphens as part of a client ID.

@wbtvc
Copy link

wbtvc commented May 3, 2018

You can fix it like this:
message/connect.go:

clientIdRegexp = regexp.MustCompile("^[0-9a-zA-Z _\\-|]*$") 

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

2 participants