# Python SDK and MTTQ Compatibility

**URL:** <https://openziti.discourse.group/t/python-sdk-and-mttq-compatibility/756>\
**Category:** SDK Questions\
**Created:** [September 19, 2022, 6:56pm UTC](https://openziti.discourse.group/t/python-sdk-and-mttq-compatibility/756 "2022-09-19T18:56:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![natashell](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/natashell/32/122_2.png) [@natashell](https://openziti.discourse.group/u/natashell)\
**Post date:** [September 19, 2022, 6:56pm UTC](https://openziti.discourse.group/t/python-sdk-and-mttq-compatibility/756/1 "2022-09-19T18:56:51Z")

</div>

Good Morning guys!  
I’m working with the Python SDK, and I just realize I’m having some issues when I try to use the Ziti SDK and the paho.mqtt.client.

My use case is quite simple. I’m integrating some devices with the Google assistant. After you ask Google to do something, the request is sent to the IoT queue and grabbed by my script. The data collected from Google is sent to a Ziti Protected Webhook.

The Webhook is working like a charm, but in the “MTTQ client” when I do a monkeypatch I can’t connect anymore to the GCP MTTQ service as I have the following error:

```auto
Traceback (most recent call last):
  File "/app/ziti_tie_desk/TIEDesk_MTTQ.py", line 466, in <module>
    listen_for_messages()
  File "/app/ziti_tie_desk/TIEDesk_MTTQ.py", line 264, in listen_for_messages
    client = get_client()
  File "/app/ziti_tie_desk/TIEDesk_MTTQ.py", line 147, in get_client
    client = mqtt.Client(client_id=client_id)
  File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 519, in __init__
    self._sockpairR, self._sockpairW = _socketpair_compat()
  File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 244, in _socketpair_compat
    listensock.bind(("127.0.0.1", 0))
  File "/usr/local/lib/python3.9/site-packages/openziti/zitisock.py", line 58, in bind
    bindings = self._ziti_opts['bindings']
KeyError: 'bindings'
Exception ignored in: <function Client. __del__ at 0x7f2e696ac790>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 603, in __del__
    self._reset_sockets()
  File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 649, in _reset_sockets
    if self._sockpairR:
AttributeError: 'Client' object has no attribute '_sockpairR'

```

On the other hand If I first do the MQTT connection and then I monkeypatch… I never reach the Ziti network.

Any ideas where to look to?

---

<div class="post-metadata">

**Author:** ![ekoby](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/ekoby/32/14_2.png) [@ekoby](https://openziti.discourse.group/u/ekoby)\
**Post date:** [September 19, 2022, 7:34pm UTC](https://openziti.discourse.group/t/python-sdk-and-mttq-compatibility/756/2 "2022-09-19T19:34:21Z")

</div>

@natashell this look like a bug, do you mind adding an issue to our repo? [Issues · openziti/ziti-sdk-py · GitHub](https://github.com/openziti/ziti-sdk-py/issues)

---

<div class="post-metadata">

**Author:** ![natashell](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/natashell/32/122_2.png) [@natashell](https://openziti.discourse.group/u/natashell)\
**Post date:** [September 19, 2022, 8:10pm UTC](https://openziti.discourse.group/t/python-sdk-and-mttq-compatibility/756/3 "2022-09-19T20:10:25Z")

</div>

Will do!  
Thanks @ekoby !

---

<div class="post-metadata">

**Author:** ![ekoby](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/ekoby/32/14_2.png) [@ekoby](https://openziti.discourse.group/u/ekoby)\
**Post date:** [September 20, 2022, 1:50pm UTC](https://openziti.discourse.group/t/python-sdk-and-mttq-compatibility/756/4 "2022-09-20T13:50:37Z")

</div>

Issue is here: [Monkeypatch affecting MQTT connections · Issue #30 · openziti/ziti-sdk-py · GitHub](https://github.com/openziti/ziti-sdk-py/issues/30)
