aisstream / issues

7 stars 3 forks source link

ConnectionResetError when running Python example. #13

Closed cb-r closed 1 year ago

cb-r commented 1 year ago

Hi, I am getting the following error stack when running your python example. I have confirmed that my api key is valid. My python version is 3.10.9

Traceback (most recent call last):
File "C:\Users\xxx\programming\example\python\main.py", line 24, in
asyncio.run(connect_ais_stream())
File "C:\Users\xxx\miniconda3\envs\tak\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\xxx\miniconda3\envs\tak\lib\asyncio\base_events.py", line 649, in run_until_complete
return future.result() File "C:\Users\xxx\programming\example\python\main.py", line 8, in connect_ais_stream async with websockets.connect("wss://stream.aisstream.io/v0/stream") as websocket: File "C:\Users\xxx\miniconda3\envs\tak\lib\site-packages\websockets\legacy\client.py", line 642, in aenter return await self File "C:\Users\xxx\miniconda3\envs\tak\lib\site-packages\websockets\legacy\client.py", line 659, in await_impl_timeout return await asyncio.wait_for(self.await_impl(), self.open_timeout) File "C:\Users\xxx\miniconda3\envs\tak\lib\asyncio\tasks.py", line 445, in wait_for return fut.result() File "C:\Users\xxx\miniconda3\envs\tak\lib\site-packages\websockets\legacy\client.py", line 663, in await_impl _transport, _protocol = await self._create_connection() File "C:\Users\xxx\miniconda3\envs\tak\lib\asyncio\base_events.py", line 1097, in create_connection transport, protocol = await self._create_connection_transport( File "C:\Users\xxx\miniconda3\envs\tak\lib\asyncio\base_events.py", line 1127, in _create_connection_transport await waiter ConnectionResetError

aisstream commented 1 year ago

We do periodically reset the connection and for this reason recommend automatic reconnections with exponential backoff when connecting to our service.

I did just try the python example and it did work for myself so I am not 100% sure what caused the issue you have noted. Please note we do close connections that attempt to reconnect more then once a second .

cb-r commented 1 year ago

The same program works now without error most of the time, but sometimes I still get the exception. Thanks.

cb-r commented 1 year ago

Are there any bounding box limits? I am unable to get any data for bounding box coords [[[152, -35], [155, -33]]], thanks.

aisstream commented 1 year ago

Keeping Your Connection Alive

At aisstream.io we use a variety of methods to determine if your connection to our service is alive and healthy. The main method we use to determine if a connection is healthy is by monitoring the amount of data in queue waiting to be read by the underlying tcp connection you have made to our service. If this queue is above a certain size aisstream.io may close your connection to our service. To prevent this from happening using an internet connection to our service with high bandwidth and sufficient resources (cpu and memory) to process on average 300 messages a second (if subscribed to the entire world) is required.

It is possible we are closing your connection because you are not consuming messages at the speed we are producing them. What are the specs of the machine you are using and where are you running the machine from in the world (continent is fine if you do not feel comfortable sharing this info) ? Due to the volume of data produced we are very sensitive to poor network quality on the clients end. We recommend that you run programs in dedicated data center with at least 250mb bandwidth also ideally in north america.

aisstream commented 1 year ago

Closing due to inactivity.