[noPoll] How to receive noPoll WebSocket ping acknowledge?

Francis Brosnan Blázquez francis en aspl.es
Dom Nov 15 11:27:29 CET 2015


El dom, 15-11-2015 a las 00:30 +0200, Rami Rosenbaum escribió:
> Hola,


Hola Rami!

> 
> Hablo muy male Espaniol, losiento...


Don't worry, I really appreciate your effort! 


> I'm using noPoll WebSocket lib within my Qt application (4.8 - no
> native web-socket API).


Right,


> Due to socket disconnections I added the PING-PONG functionality.


Ok,


> My intention was to recreate the web-socket if n PINGs fail.
> Looking at the noPoll logs - I'm receiving PONGs.
> Ho do I know if the PING fails?
> The call nopoll_conn_send_ping() always returns (2), even on
> success...


Ok, several elements here. In one hand, going to your question, if
nopoll_conn_send_ping
returns 2, it means it succeeded and it sent the PING frame. So if you
run the following
code you can check if it failed:

   if (! nopoll_conn_send_ping (conn)) {
         // handle ping failure here
   }

At the other hand, nopoll_conn_send_ping shouldn't be returning (2) but
nopoll_true or
nopoll_false. I've updated github repo to include a fix to make this,

        

https://github.com/ASPLes/nopoll/commit/b78aa65b5e9a44c2673cb0b125f88412de7f3c75




> If I disconnect the internet connection - how can I catch a 'fail' or
> timeout?


Ok, for a failure, you can connect a handler to get a connection close
using:
  
   nopoll_conn_set_on_close (conn, on_disconnect_handler)

...but for the timeout, possibly we can add an "on pong received"
handler, so you
can set a timeout and if that timeout is reached (without being
cancelled by the code
at your "on pong received") then you can consider timeout reached and
close the connection
or handle the way it is needed.

However, currently, as PING/PONG frames are defined now, they are more
for a keep alive mechanism to ensure
the transport is working instead of handling timeouts... for example,
ping/pong frames do not 
have an indicator so you can track what ping frame is being replied when
a pong is received..

Having said that, I think the best way to go here is you send an
application level "ping" that
your application can reply/handle (even including some state) and then
inside your on msg received
handler you can also check if there are pending replies or if a timeout
was reached,

Best Regards,

> 
> Thanks,
> 
> 
> Rami
> 
> 
> _______________________________________________
> noPoll mailing list
> noPoll en lists.aspl.es
> http://lists.aspl.es/cgi-bin/mailman/listinfo/nopoll


-- 
Francis Brosnan Blázquez  -  ASPL
http://www.asplhosting.com/
http://www.aspl.es/
https://twitter.com/aspl_es
https://twitter.com/asplhosting
https://twitter.com/francisbrosnanb

91 134 14 22 - 91 134 14 45 - 91 116 07 57

AVISO LEGAL
 
En virtud de lo dispuesto en la Ley Orgánica 15/1999, de 13 de
diciembre, de Protección de Datos de Carácter Personal, le informamos de
que sus datos de carácter personal, recogidos de fuentes accesibles al
público o datos que usted nos ha facilitado previamente, proceden de
bases de datos propiedad de Advanced Software Production Line, S.L.
(ASPL).
 
ASPL garantiza que los datos serán tratados con la finalidad de mantener
las oportunas relaciones comerciales o promocionales con usted o la
entidad que usted representa. No obstante, usted puede ejercitar sus
derechos de acceso, rectificación, cancelación y oposición dispuestos en
la mencionada Ley Orgánica, notificándolo por escrito a ASPL -
Protección Datos, C/Antonio Suárez 10 A-102, 28802, Alcalá de Henares
(Madrid).


------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://lists.aspl.es/pipermail/nopoll/attachments/20151115/b0b15f14/attachment.html>


Más información sobre la lista de distribución noPoll