Python SDK ClientHandler initiation throws error

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.

Did you see Python SDK discontinued, alternatives?

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.

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

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

Thanks for the help!