-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
when using an address without :// mqttclient_create does not cause an error #1480
Comments
Which version of the library are you using? |
libpaho-mqtt3c.so.1.3 |
There is only a 1.3.0 version but no 1.3. Try the latest version |
i tried it on 1.3.13 and it returns 0 on MQTTClient_create and -1 on MQTTClient_connect when the address starts with tcp: |
The connect function (in getaddrinfo) validates the address format, so the idea was not to (imperfectly) duplicate function which already exists in getaddrinfo. The switch on tcp://, ssl://, ws:// is mainly there to select the right protocol to use - an empty string defaults to TCP. With your erroneous string, the protocol trace looks like this: Trace : 5, 19700101 010000.000 getaddrinfo failed for addr tcp:test.mosquitto.org with rc 8 One request on the todo list for a while is improved connection errors #937, which although are available in the trace or error callbacks, could be surfaced more readily. |
Describe the bug
i mistyped the address as tcp:ip:port instead of tcp://ip:port but it did not cause an error while creating the client and only a generic error while connecting.
the problem lies in the implementation where there is no error or default handling when the :// part of the string cannot be found.
To Reproduce
change the address in the publish example and remove the // after tcp
run the code
Expected behavior
the client creation function returns an error stating the address is invalid
** Environment (please complete the following information):**
The text was updated successfully, but these errors were encountered: