websocket ping-pong implementation

Skip to first unread message

John Lima

Oct 29, 2013, 11:58:51 AM10/29/13
to mongoos...@googlegroups.com

Has anyone tried implementing websocket ping-pong messages on top of mongoose websockets?

I'd like to avoid adding a new thread per connection to send ping packets and because my list of active connections isn't in a threadsafe datastructure, it doesn't seem feasible to send the pings for all connections from one thread.

My current idea is to rejigger another thread that handles the connection list data structure to occasionally stop its normal operation and sing the ping packets, but this doesn't feel like a very good solution.

Any suggestions?

Thanks in advance!


Sergey Lyubka

Oct 29, 2013, 11:22:34 PM10/29/13
to mongoose-users
Reading RFC, it looks like either side (browser or server) may initiate ping.
What is your intention, is it making server send pings?
Is it for checking that browser is still connected?

You received this message because you are subscribed to the Google Groups "mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-user...@googlegroups.com.
To post to this group, send email to mongoos...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/groups/opt_out.

John Lima

Oct 30, 2013, 11:02:59 AM10/30/13
to mongoos...@googlegroups.com
I'm trying to get the server side to send pings.

My use case is that it seems Mongoose won't exit when there is a websocket connected because a worker thread is blocked on a read. I'm thinking that the pong reply will unblock the thread, allowing it to realize that it should exit.

I'm also doing it as a keep alive, so I can have timeouts on normal HTTP requests while still having long-lived "idle" websockets.


Sergey Lyubka

Oct 30, 2013, 7:10:30 PM10/30/13
to mongoose-users
Reply all
Reply to author
0 new messages