WebSocket-for-Python icon indicating copy to clipboard operation
WebSocket-for-Python copied to clipboard

Heartbeat Pong Message (why not Ping?)

Open grubberr opened this issue 11 years ago • 4 comments

Hello,

I am curious why in Heartbeat context manager you send PongControlMessage ?

https://github.com/Lawouach/WebSocket-for-Python/blob/master/ws4py/websocket.py#L55

for me more logically to send PingControlMessage ?

Thanks in advance!

grubberr avatar Sep 30 '14 06:09 grubberr

Hi,

2014-09-30 8:08 GMT+02:00 grubberr [email protected]:

Hello,

I am curious why in Heartbeat context manager you send PongControlMessage ?

https://github.com/Lawouach/WebSocket-for-Python/blob/master/ws4py/websocket.py#L55

for me more logically to send PingControlMessage ?

Thanks in advance!

I think I always considered the heartbeat to be a receiver of Ping messages but you have a point actually. Mind you, these days the class is still there but not uactually used anyhow. Well, unless you directly create a WebSocket instance yourself and call its run method. This is not used by any of the server/client in ws4py anylonger.

  • Sylvain http://www.defuze.org http://twitter.com/lawouach

Lawouach avatar Sep 30 '14 06:09 Lawouach

reading some simple articles about websocket I initially also thought that websocket library has to re-connect using some ping-pong heartbeat

maybe re-implementing this Hearbeat class for receiving pings really good point

anyway in my code I have own heartbeat thread which checks if connection alive using incoming data and I want to re-implement based on incoming ping messages

but I am stuck on such thing:

I cannot find method which will be executed if ping message arive

I only need to patch ws4py

grubberr avatar Sep 30 '14 09:09 grubberr

I think I ought to implement a "pinged()" handler indeed.

Lawouach avatar May 11 '15 07:05 Lawouach

Hi,

We're using ws4py and need finer grained control over ping/pong handling. We really could use a 'pong_received' event handler and a method to manually trigger the sending of a ping message. This, in addition to regular periodic ping requests being automatically generated by ws4py.

that is, we need to know when the remote end has responded to our ping request, to manually initiate a ping request and to have a regular ping request sent.

bonus if we also could have a ping_received event as well.

thanks

bkcsfi avatar Jul 20 '15 19:07 bkcsfi