Hello everyone,
I am running a WebSocket client on a cloud instance that receives messages from a WebSocket data provider and writes them into an InfluxDB container hosted locally on the same cloud instance. The system ran fine for about two days, but then it started continuously giving me a maximum recursion depth error.
InfluxDBv2 OSS
Docker Image : influxdb:latest
Python Client v1.44.0
Error Logs:
ERROR - error from callback <function on_message at 0x7f77fbe9e430>: maximum recursion depth exceeded in comparison
websocket-client_1 | ERROR - Error: maximum recursion depth exceeded in comparison
websocket-client_1 | ERROR - Failed to write message 4682252 to influxDB: maximum recursion depth exceeded in comparison
websocket-client_1 | ERROR - Data: \g:1-2-1657,s:rORBCOMM000,c:1719759229*56\!AIVDM,2,1,7,A,53pr=Q81q7rm=4iD000tAU<0000000000000000l1@I364u80=4Slm3hjjh0,0*22
websocket-client_1 | ERROR - Traceback (most recent call last):
websocket-client_1 | File "/app/src/utils/db_utils.py", line 31, in store_to_influxdb
websocket-client_1 | write_api.write(bucket="nmea_data", record=point)
websocket-client_1 | File "/usr/local/lib/python3.9/site-packages/influxdb_client/client/write_api.py", line 381, in write
websocket-client_1 | results = list(map(write_payload, payloads.items()))
websocket-client_1 | File "/usr/local/lib/python3.9/site-packages/influxdb_client/client/write_api.py", line 379, in write_payload
websocket-client_1 | return self._post_write(_async_req, bucket, org, final_string, payload[0])
websocket-client_1 | File "/usr/local/lib/python3.9/site-packages/influxdb_client/client/write_api.py", line 516, in _post_write
websocket-client_1 | return self._write_service.post_write(org=org, bucket=bucket, body=body, precision=precision,
websocket-client_1 | File "/usr/local/lib/python3.9/site-packages/influxdb_client/service/write_service.py", line 60, in post_write
websocket-client_1 | (data) = self.post_write_with_http_info(org, bucket, body, **kwargs) # noqa: E501
websocket-client_1 | File "/usr/local/lib/python3.9/site-packages/influxdb_client/service/write_service.py", line 90, in post_write_with_http_info
websocket-client_1 | return self.api_client.call_api(
websocket-client_1 | File "/usr/local/lib/python3.9/site-packages/influxdb_client/_sync/api_client.py", line 343, in call_api
websocket-client_1 | return self.__call_api(resource_path, method,
websocket-client_1 | File "/usr/local/lib/python3.9/site-packages/influxdb_client/_sync/api_client.py", line 173, in __call_api
websocket-client_1 | response_data = self.request(
websocket-client_1 | File "/usr/local/lib/python3.9/site-packages/influxdb_client/_sync/api_client.py", line 388, in request
websocket-client_1 | return self.rest_client.POST(url,
websocket-client_1 | File "/usr/local/lib/python3.9/site-packages/influxdb_client/_sync/rest.py", line 311, in POST
websocket-client_1 | return self.request("POST", url,
websocket-client_1 | File "/usr/local/lib/python3.9/site-packages/influxdb_client/_sync/rest.py", line 220, in request
websocket-client_1 | r = self.pool_manager.request(
websocket-client_1 | File "/usr/local/lib/python3.9/site-packages/urllib3/_request_methods.py", line 144, in request
websocket-client_1 | return self.request_encode_body(
websocket-client_1 | File "/usr/local/lib/python3.9/site-packages/urllib3/_request_methods.py", line 255, in request_encode_body
websocket-client_1 | extra_kw: dict[str, typing.Any] = {"headers": HTTPHeaderDict(headers)}
websocket-client_1 | File "/usr/local/lib/python3.9/site-packages/urllib3/_collections.py", line 249, in __init__
websocket-client_1 | self.extend(headers)
websocket-client_1 | File "/usr/local/lib/python3.9/site-packages/urllib3/_collections.py", line 351, in extend
websocket-client_1 | elif isinstance(other, typing.Mapping):
websocket-client_1 | File "/usr/local/lib/python3.9/typing.py", line 720, in __instancecheck__
websocket-client_1 | return self.__subclasscheck__(type(obj))
websocket-client_1 | File "/usr/local/lib/python3.9/typing.py", line 852, in __subclasscheck__
websocket-client_1 | return issubclass(cls, self.__origin__)
websocket-client_1 | File "/usr/local/lib/python3.9/abc.py", line 123, in __subclasscheck__
websocket-client_1 | return _abc_subclasscheck(cls, subclass)
websocket-client_1 | RecursionError: maximum recursion depth exceeded in comparison
websocket-client_1 |
websocket-client_1 | ERROR - error from callback <function on_message at 0x7f77fbe9e430>: maximum recursion depth exceeded in comparison
My write Funcion:
def store_to_influxdb(data, count):
try:
point = (
influxdb_client.Point("raw_ais_messages")
.time(datetime.utcnow(), influxdb_client.WritePrecision.NS)
.field("data", data)
)
write_api.write(bucket="nmea_data", record=point)
if count % 1000 == 0:
logger.info(f"Message {count} stored to InfluxDB successfully")
except Exception as e:
logger.error(f"Failed to write message {count} to influxDB: {e}")
logger.error(f"Data: {data}")
logger.error(traceback.format_exc())
raise