Hello @Pandey, Yogesh ,
this could either be a problem with the MQTT traffic or some coding issue.
Is MQTT traffic allowed in your network or are extra proxy settings needed (perhaps on a corporate network)?
Otherwise, did you check this 'most simple' demonstrations first?
Recently, I checked these Python sample code from Microsoft, and I was able to both send telemetry and receive commands using those examples.
I suggest checking this out first before you switch over to the more elaborate Plug and Play example.
The Python script I constructed with the full solution is available on GitHub. It's a combination of those SDK samples. More background information is seen here.
Hello @Pandey, Yogesh ,
The IoT Hub supports multiple protocols.
MQTT can also be done over WebSockets (port 443).
This WebSocket communication looks like HTTPS so probably this will be supported.
Check out this sample where websockets are activated (the sample is part of a bigger 'proxy' picture).
Using Azure IoT Edge will not help you in this case, because it uses the same protocol selection...
Thanks for the reply.
I tried this sample as well. Still, I am running into a similar issue.
I think the SDK only supports MQTT and not other protocols. https://github.com/Azure/azure-iot-sdk-python#features
$ python3 send_message_via_proxy.py
Traceback (most recent call last):
File "/home/intel/.local/lib/python3.6/site-packages/azure/iot/device/common/mqtt_transport.py", line 391, in connect
host=self._hostname, port=443, keepalive=self._keep_alive
File "/home/intel/.local/lib/python3.6/site-packages/paho/mqtt/client.py", line 914, in connect
return self.reconnect()
File "/home/intel/.local/lib/python3.6/site-packages/paho/mqtt/client.py", line 1044, in reconnect
sock = self._create_socket_connection()
File "/home/intel/.local/lib/python3.6/site-packages/paho/mqtt/client.py", line 3683, in _create_socket_connection
return socks.create_connection(addr, timeout=self._connect_timeout, source_address=source, **proxy)
File "/home/intel/.local/lib/python3.6/site-packages/socks.py", line 180, in create_connection
for r in socket.getaddrinfo(proxy_addr, proxy_port, 0, socket.SOCK_STREAM):
File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
Hello
I tested my own example again and added the Websockets setting:
This is now updated at my sample code repo. Please check out this sample again.
Double-check if the connection string is read from the environment variables on your setup.
If this is still not working, it's probably the network or your python runtime.
Sign in to comment