I am a having a very strange issue. The premise is that I am fairly ignorant in both mqtt and python (the latter I don't use it now since at least 5-6 years), but I am making a Unity app for a museum using a 3D tracking system (www.pozyx.io) and I need each of my machines to run a small mqtt-to-OSC client, so that my Unity app can read the position data from the client.
On my development machine, it all works like a charm, using a slightly modified version of the script provided by the sensor producer.
`
API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
import paho.mqtt.client as mqtt
import ssl
import json
from pythonosc.udp_client import SimpleUDPClient
host = "mqtt.cloud.pozyxlabs.com"
port = 443
topic = "5c500595601a3f5871a17685"
username = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
password = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
ip = "127.0.0.1" # IP for the OSC UDP
network_port = 8888 # network port for the OSC UDP
osc_udp_client = SimpleUDPClient(ip, network_port)
def on_connect(client, userdata, flags, rc):
print(mqtt.connack_string(rc))
def on_message(client, userdata, msg):
tag_data = json.loads(msg.payload.decode())
for tag in tag_data:
try:
network_id = tag["tagId"]
#print(network_id)
timestamp = tag["timestamp"]
position = tag["data"]["coordinates"]
yaw = tag["data"]["orientation"]["yaw"]
osc_udp_client.send_message("/position", [network_id, timestamp, position["x"], position["y"], position["z"], yaw])
except:
print("Received a bad packet?")
pass
def on_subscribe(client, userdata, mid, granted_qos):
print("Subscribed to topic!")
client = mqtt.Client(transport="websockets")
client.username_pw_set(username, password=password)
client.tls_set_context(context=ssl.create_default_context())
client.on_connect = on_connect
client.on_message = on_message
client.on_subscribe = on_subscribe
client.connect(host, port=port)
client.subscribe(topic)
client.loop_forever()
`
Now that I am in the musem to deploy, of course on the freshly setup windows 10 machines ( I tried both on a NUC and and on a Lenovo Thinkpad), nothing works, and I get each time the following error
C:\Users\Vattenkikare1\Desktop\osc_hans>py osc_hans.py Traceback (most recent call last): File "osc_hans.py", line 67, in client.connect(host, port=port) File "C:\Users\Vattenkikare1\AppData\Local\Programs\Python\Python37-32\lib\site-packages\paho\mqtt\client.py", line 839, in connect return self.reconnect() File "C:\Users\Vattenkikare1\AppData\Local\Programs\Python\Python37-32\lib\site-packages\paho\mqtt\client.py", line 994, in reconnect sock.do_handshake() File "C:\Users\Vattenkikare1\AppData\Local\Programs\Python\Python37-32\lib\ssl.py", line 1117, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)
My laptop is plugged onto the same WiFi and I do have admin rights on all the machines. Would you have any idea on what might be causing the problem? And why might that happen only on the other computers and not on mine? I did first deploy an exe to those machines, but then on one of them i did a quick python setup with all the modules, but nothing changed.
I did find a few similar issues around, but none that I could relate directly to mine in terms of solution.
I seem to have found the solution in the most random way. I noticed on a post that the Pozyx.io website used the "COMODO RSA Domain Validation Secure Server CA" certificate, and even though the API documentation didn't mention it, I installed it on the test computers and all started working.