Open sato-s opened 6 years ago
Hi,
mqtt is currently not in the IANA URI schemes list, though there is a proposal to request that it be added for MQTTv5 (https://issues.oasis-open.org/browse/MQTT-203). I'm going to wait until there is an official IANA URI scheme added for mqtt before adding it to either the V3.1.1 or the V5 clients. It may also be the case that the scheme is only valid for MQTTv5, if this becomes the case, then we will only add it to the v5 client.
Thank you for your reply.
I understand there's a good reason not to accept mqtt://
for now.
Wait, doesn't this straight mean that we can't use this library against, like, half the services out there using MQTT? Is it really necessary for the scheme to be de jure standardized for the library to allow it, when it already seems to be the de facto standard?
This is my first time using the library to connect to an external service, and they just use "mqtt://" as the scheme. What am I supposed to do? Is there any workaround?
One could use something like this to hack around
from urllib.parse import urlparse
import paho.mqtt.client as mqtt
def connect_uri(client, uri):
uri_parts = urlparse(uri)
default_port = 1883
if uri_parts.username:
client.username_pw_set(uri_parts.username, uri_parts.password)
if uri_parts.scheme == 'mqtts':
default_port = 8883
client.tls_set()
client.connect(uri_parts.hostname,
uri_parts.port if uri_parts.port else default_port)
mqttc = mqtt.Client()
connect_uri(mqttc, 'mqtts://foo:bar@mqtt.eclipseprojects.io')
I tried to connect my server with a URL like a
mqtt://***
but was unsuccessful. It started work properly after usingtcp://
.According to following code,
mqtt://
raises IllegalArgumentException. https://github.com/eclipse/paho.mqtt.java/blob/master/org.eclipse.paho.jmeclient/org.eclipse.paho.jmeclient.mqttv3/src/org/eclipse/paho/client/mqttv3/MqttConnectOptions.java#L388I think specifying
mqtt://
is common way to clarify a server is running mqtt protocol. Could you allowmqtt://
for beginners like me?