Python Integration


I am trying to integrate the lorawan gateway with a python code to harvest data from the nodes.

Compelted all the setup, and i can read the datas from chirpstack and postman wss connection without any problem. But when i try to make an application for it i cannot connect and get data from it. Tried various library but cannot find any solution. Some of examples gives SSL error and some of them i cannot pass the jwt token.

import requests
from requests.auth import HTTPDigestAuth
import warnings
import os
import sys
import grpc
import websocket
from websocket import create_connection
import websockets
import asyncio
import pathlib
import ssl
from chirpstack_api.as_pb.external import api

url = ""

data ={
          "email": "",
          "password": "Batw1ngs-Adm1n1!"

response =, json=data, verify=False)
print("Status Code:", response.status_code)
jwt = str(response.json())
jwt = jwt.split("'")[3]

ssl_context = ssl.SSLContext()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
#todo kluge
uri = "wss://@"
header=("Sec-WebSocket-Protocol: Bearer,")
created = ("\n"+token)
list1 = ["Sec-WebSocket-Protocol", created]
async def hello():
##    async with websockets.connect(uri, ssl=ssl_context) as websocket:
    async with websockets.connect(
        extra_headers={"Bearer,": f"token"}
        ) as websocket:
        greeting = await websocket.recv()
        print(f"< {greeting}")

Please help.
Thanks in advance.

This is not the recommended route to consume device data, and it is very likely that this will break. Assuming you are using ChirpStack v3, please take a look at the documentation: HTTP - ChirpStack open-source LoRaWAN<sup>®</sup> Network Server