Ping-pong example

1,345 views
Skip to first unread message

jimbo...@gmail.com

unread,
Aug 9, 2014, 1:41:04 PM8/9/14
to webso...@googlegroups.com
Peter,

I'm live testing my app now on the internet, and it is simply amazing!  I love how much thought you've put into automating the whole process!  I love that running out of file descriptors is simply rolled over without crashing the app!  I love that a connection_hdl is not fully dependent upon the endpoint!  Simply, I love that you've made this so comprehensive, I don't have to think and can spend all of my time on the meat of my app!

When testing on my LAN, as soon as a connection was lost, the close handler's fired.  However, something gets lost on the internet, and I'm having the same issue as Max: https://groups.google.com/forum/#!searchin/websocketpp/ping/websocketpp/Lf-ghuabioU/q-hNMz44G80J

I've gone through the source and setup handlers, but I'm having trouble setting them.

I'm trying to do it in the flavor of the main handlers:
m_client.set_ping_handler(bind(&broadcast_server::on_m_client_ping,this,::_1,::_2));

But this won't take.  I've tried removing the placeholders in part and whole, and I still get an error.

I setup a typedef and every possible combination I can think of with set_ping_handler, but I still get errors.

How should this be setup?

Also, I'm only trying to detect a pong failure.  Is the string message necessary to this process?

Thank you so much in advance and for the most important web library for as far as I can see!
 

jimbo...@gmail.com

unread,
Aug 9, 2014, 2:07:02 PM8/9/14
to webso...@googlegroups.com

Peter Thorson

unread,
Aug 9, 2014, 4:17:31 PM8/9/14
to jimbo...@gmail.com, webso...@googlegroups.com
Tanuki’s answer to this stack overflow question looks correct to me.

Regarding some of your other questions from the previous note:

Also, I'm only trying to detect a pong failure.  Is the string message necessary to this process?

If you are using ping/pong to detect a failed connection you probably want to have your program send a ping and then use the pong handler and the pong_timeout handler to decide what to do next. The pong handler is called when you receive a pong response from the other endpoint. The pong timeout handler is called after a ping goes unanswered by a pong message for a period of time. The binary ping data payload (what you are calling string message here) is used to differentiate multiple pong responses from each other. It may be blank if you don’t need to differentiate one pong from another (for example if you only ever have one outstanding).

In general, if the other endpoint can answer a ping then its network and WebSocket stack are likely to be still working. It doesn’t guarantee the rest of the endpoint is working, but it should fairly quickly detect cases where the socket is actually closed uncleanly.

On Aug 9, 2014, at 13:07, jimbo...@gmail.com wrote:

Crosspost:  http://stackoverflow.com/questions/25221566/how-to-implement-websocket-ping-handler

--
You received this message because you are subscribed to the Google Groups "WebSocket++" group.
To unsubscribe from this group and stop receiving emails from it, send an email to websocketpp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jimbo...@gmail.com

unread,
Aug 9, 2014, 4:34:58 PM8/9/14
to webso...@googlegroups.com, jimbo...@gmail.com
Peter, I really can't tell you how genius I think you are!  This lib is simply too great!

For any other noobs out there: my mistake was using a different return type for the function.  I was using void when I should've been using bool in this case.


Reply all
Reply to author
Forward
0 new messages