eclipse / paho.mqtt.python

paho.mqtt.python
Other
2.15k stars 724 forks source link

Find no 'path=' option for single messages #732

Open sosyco opened 1 year ago

sosyco commented 1 year ago

Hi, I want to send a single message to wss://mydomain/mqtt behind a proxy.

Mosquitto and NGINX work fine. I can send messages via websocket to the defined path via MQTTX. Same via full-client-code.

BUT using the single function, I see no option for path ("/mqtt")

If I use websocket without path but a special domain (wss://mqtt.mydomain), all works fine. But this is not my intention.

A code example:

import paho.mqtt.publish as mqttpublish
import certifi
...
mqtt_auth = { 'username': USER, 'password': PASSWORD }
# where can i set the path='/mqtt'?
mqttpublish.single(TOPIC, payload=MSG, qos=1, retain=True, hostname=BROKER, port=443, client_id=CLIENTID, keepalive=60, will=None, auth=mqtt_auth, tls={'ca_certs':certifi.where()}, transport='websockets')
MattBrittan commented 7 months ago

/mqtt should be the default path; so you should not need to specify this.

It does not look like single provides any way to change this; for now you would need to copy the code (it's relatively short) and add a call to ws_set_options.