Welcome to Animus Talk

This is where users of Animus Heart can share ideas,
solve problems and inspire fellow enthusiasts.

Animus Heart?

Properly pinging Animus Heart to avoid the websocket connection from timing out

Hello everyone!

I’m a professional developer for going on over 2 decades. I’ve worked with many different programming languages such as C++, Java, C# and Delphi over the years but for this particular project, I decided to challenge myself to do it Python that I have zero experience from which could possibly contribute to my confusion on my problem right now.

I’m using the websockets library for Python 3 that’s built on top of the asyncio library. By default, connections made using this library will send websocket ping frames every 20 seconds with some random data to be able to tell the pong-replies apart. Judging from the logs, this looks like it is working well and the appropriate pong-replies are received from the Heart:

DEBUG:websockets.protocol:client > Frame(fin=True, opcode=9, data=b'\xa7\x8a\xbb<', rsv1=False, rsv2=False, rsv3=False)
DEBUG:websockets.protocol:client - event = data_received(<6 bytes>)
DEBUG:websockets.protocol:client < Frame(fin=True, opcode=10, data=b'\xa7\x8a\xbb<', rsv1=False, rsv2=False, rsv3=False)
DEBUG:websockets.protocol:client - received solicited pong: a78abb3c

however, the connection is still closed by the Heart after one minute. In my mind, as long as the websocket standard protocol pingponging is going on, this should not happen.

Since the documentation states that the pings should be sent without data, I tried sending extra ping frames without data every 30 seconds. Again, the Heart properly responds with data-less pongs, but the connection is still closed after one minute:

DEBUG:websockets.protocol:client > Frame(fin=True, opcode=9, data=b'', rsv1=False, rsv2=False, rsv3=False)
DEBUG:websockets.protocol:client - event = data_received(<2 bytes>)
DEBUG:websockets.protocol:client < Frame(fin=True, opcode=10, data=b'', rsv1=False, rsv2=False, rsv3=False)
DEBUG:websockets.protocol:client - received solicited pong: [empty]

I also tried sending simple text data messages containing the word “ping”. This does not result in any kind of response from the Heart, but interestingly, the connection does not time-out…

The documentation says that the Heart should reply when properly pinged, so I’m clearly doing something wrong here and would really appreciate it if someone could enlighten me as to correct way to ping my heart :slight_smile: