wanting to write a python script that listens to websocket using pygNMi and collect data data, however I keep getting a "grpc._channel._MultiThreadedRendezvous" error. this is the code below:
Modules
from pygnmi.client import gNMIclient, telemetryParser
from inventory import hosts
import pprint
# Body
for host_entry in hosts:
if host_entry["nos"] == "Ciena": # network operating system
print(host_entry)
subscribe = {
'subscription': [
{
'path': '', # path
'mode': 'sample', #collects the full data
'sample_interval': 10000000000
}
],
'mode': 'stream',
'encoding': 'proto',
#'target': 'pm'
}
if __name__ == '__main__':
with gNMIclient(target=(host_entry["ip_address"], host_entry["port"]),
username=host_entry["username"], password=host_entry["password"], skip_verify=True, debug=True) as gc:
telemetry_stream = gc.subscribe(subscribe=subscribe)
for telemetry_entry in telemetry_stream:
raw_data = telemetryParser(telemetry_entry)
pp = pprint.PrettyPrinter(indent=2)
pp.pprint(raw_data)
this is the error message i'm getting:
Traceback (most recent call last):
File "C:\Users\e030734\Desktop\python_decoder\main.py", line 30, in <module>
for telemetry_entry in telemetry_stream:
File "C:\Users\e030734\AppData\Local\Programs\Python\Python312\Lib\site-packages\grpc\_channel.py", line 540, in __next__
return self._next()
^^^^^^^^^^^^
File "C:\Users\e030734\AppData\Local\Programs\Python\Python312\Lib\site-packages\grpc\_channel.py", line 949, in _next
raise self
grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
status = StatusCode.CANCELLED
details = "Channel closed!"
debug_error_string = "UNKNOWN:Error received from peer {grpc_message:"Channel closed!", grpc_status:1, created_time:"2024-02-26T02:19:48.7908298+00:00"}"
I want it to listen to the channel and recieve data.