[noPoll] How to receive noPoll WebSocket ping acknowledge?

Francis Brosnan Blázquez francis en aspl.es
Dom Nov 15 15:12:54 CET 2015


Buenas Rami,

> gracias pur la rapida respuesta,


De nada :-)

> 
> So, I understand (I'm quite new to Web-Sockets) that the native
> PING/PONG utility is for holding a socket open (above the TCP
> keep-alive, that may not be configured),


That's right,


>  not for validating the socket?


Uhmn...I'm not sure about what you mean here, but certainly, it is,
mostly, for holding
the connection open,

> If that is the case - I agree, the application-layer shouldn't know
> about it.


Ok,

> 
> And, if my Web-Socket client needs to 'manually' send a PING upon an
> application-configured timeout, it may already send an
> application-level PING (as you suggested at the end of your reply).
> The only difference will be adding the application-level PING to both
> client and server, as apposed to add the "on ping received" handler
> within the noPoll lib.


That's right,

> 
> I wonder if adding a PING (say - every 30 seconds) will fix the
> disconnection issues...


Possibly. Try to see what happens. Just clarify that there's nothing in
noPoll that will
close the connection after some inactivity period ...even in the RFC, so
if you are receiving
a connection close/disconnect, maybe it is a matter of checking why is
that happening too
(at the server side), and also consider a connection issue itself,

For example, in one of our cases, we use noPoll for server side
Core-Admin [1] component 
and it provides support to web-client incoming connections using
WebSocket that lasts days 
or weeks running the same connection. In that context, no ping
(application level nor 
WebSocket) is used..

Best Regards,

[1] http://www.core-admin.com


> 
> Thanks again.
> 
> 
> 
> On 15 November 2015 at 12:27, Francis Brosnan Blázquez
> <francis en aspl.es> wrote:
> 
>         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).
>         
>         
> 
> 
> 

-- 
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/1125cd4f/attachment.html>


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