# Python SDK ClientHandler initiation throws error

**URL:** <https://www.thethingsnetwork.org/forum/t/python-sdk-clienthandler-initiation-throws-error/33315>\
**Category:** Home Automation\
**Created:** [January 11, 2020, 4:45pm UTC](https://www.thethingsnetwork.org/forum/t/python-sdk-clienthandler-initiation-throws-error/33315 "2020-01-11T16:45:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![saliniv](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/saliniv/32/31331_2.png) [@saliniv](https://www.thethingsnetwork.org/forum/u/saliniv)\
**Post date:** [January 11, 2020, 4:45pm UTC](https://www.thethingsnetwork.org/forum/t/python-sdk-clienthandler-initiation-throws-error/33315/1 "2020-01-11T16:45:11Z")

</div>

Hi Everyone,

I’m trying to create my own smart home application using TTN python SDK. I started by using the example code, as written below:

> app\_id = “foo”  
> access\_key = “ttn-account.\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*”  
> def uplink\_callback(msg, client):  
> print("Received uplink from ", msg.dev\_id)  
> print(msg)  
> **handler = ttn.HandlerClient(app\_id, access\_key)**

Where I provided correct App ID and access key, and the rest of the parameters used are the default (such as discovery address etc.)

Unfortunately, I get the following error:

> Traceback (most recent call last):  
> File “C:/Users/Alon\_Berman/Desktop/TempMonitor/temperature\_monitor/server/ttn\_client.py”, line 17, in   
> handler = ttn.HandlerClient(app\_id, access\_key)  
> File “C:\Users\Alon\_Berman\Desktop\TempMonitor\temperature\_monitor\venv\lib\site-packages\ttn\handler.py”, line 32, in **init**  
> self.\_\_open(discovery\_address)  
> File “C:\Users\Alon\_Berman\Desktop\TempMonitor\temperature\_monitor\venv\lib\site-packages\ttn\handler.py”, line 47, in \_\_open  
> self.announcement = discovery.get\_by\_app\_id(self.app\_id)  
> File “C:\Users\Alon\_Berman\Desktop\TempMonitor\temperature\_monitor\venv\lib\site-packages\ttn\discovery.py”, line 54, in get\_by\_app\_id  
> return self.client.GetByAppID(req)  
> File “C:\Users\Alon\_Berman\Desktop\TempMonitor\temperature\_monitor\venv\lib\site-packages\grpc\_channel.py”, line 824, in **call**  
> return \_end\_unary\_response\_blocking(state, call, False, None)  
> File “C:\Users\Alon\_Berman\Desktop\TempMonitor\temperature\_monitor\venv\lib\site-packages\grpc\_channel.py”, line 726, in \_end\_unary\_response\_blocking  
> raise \_InactiveRpcError(state)  
> grpc.\_channel.\_InactiveRpcError: \<\_InactiveRpcError of RPC that terminated with:  
> status = StatusCode.UNKNOWN  
> details = “Stream removed”  
> debug\_error\_string = “{“created”:”@1578742144.428000000",“description”:“Error received from peer ipv4:52.178.215.58:1900”,“file”:“src/core/lib/surface/call.cc”,“file\_line”:1056,“grpc\_message”:“Stream removed”,“grpc\_status”:2}"

I tried to look for any clues on the internet, but I couldn’t find any useful information about it.  
Perhaps someone can clarify why the application fails to instantiate the ClientHandler object?

Thanks in advance!  
Alon.

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [January 12, 2020, 10:34am UTC](https://www.thethingsnetwork.org/forum/t/python-sdk-clienthandler-initiation-throws-error/33315/2 "2020-01-12T10:34:05Z")

</div>

Did you see [Python SDK discontinued, alternatives?](https://www.thethingsnetwork.org/forum/t/python-sdk-discontinued-alternatives/32597)

---

<div class="post-metadata">

**Author:** ![saliniv](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/saliniv/32/31331_2.png) [@saliniv](https://www.thethingsnetwork.org/forum/u/saliniv)\
**Post date:** [January 12, 2020, 7:11pm UTC](https://www.thethingsnetwork.org/forum/t/python-sdk-clienthandler-initiation-throws-error/33315/3 "2020-01-12T19:11:58Z")

</div>

Hi, Thank you for your response!

I have seen it. Since the OP mentioned that he has no such object at all, and I do have it in the ttn library, I thought it’s still possible to work with it someway.

So there is absolutely no way of communicating with TTN using Python?  
I only need it to retrieve data from my node, if it helps somehow.

---

<div class="post-metadata">

**Author:** ![kersing](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kersing/32/44777_2.png) [@kersing](https://www.thethingsnetwork.org/forum/u/kersing)\
**Post date:** [January 12, 2020, 7:44pm UTC](https://www.thethingsnetwork.org/forum/t/python-sdk-clienthandler-initiation-throws-error/33315/4 "2020-01-12T19:44:32Z")

</div>

> [@saliniv](#):
>
> So there is absolutely no way of communicating with TTN using Python?

How about using a generic MQTT client library? Just connect to TTN, subscribe and catch the data as it arrives. 😁

---

<div class="post-metadata">

**Author:** ![saliniv](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/saliniv/32/31331_2.png) [@saliniv](https://www.thethingsnetwork.org/forum/u/saliniv)\
**Post date:** [January 17, 2020, 6:57pm UTC](https://www.thethingsnetwork.org/forum/t/python-sdk-clienthandler-initiation-throws-error/33315/5 "2020-01-17T18:57:40Z")

</div>

Yep. It did the trick. I was overthinking things.

Thanks for the help!
