Discussion:
websocket ping-pong implementation
John Lima
2013-10-29 15:58:51 UTC
Permalink
Hello,

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!

John
--
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-users+***@googlegroups.com.
To post to this group, send email to mongoose-***@googlegroups.com.
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/groups/opt_out.
Sergey Lyubka
2013-10-30 03:22:34 UTC
Permalink
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?
Post by John Lima
Hello,
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!
John
--
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
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/groups/opt_out.
--
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-users+***@googlegroups.com.
To post to this group, send email to mongoose-***@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
2013-10-30 15:02:59 UTC
Permalink
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.

Thanks!
Post by Sergey Lyubka
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?
Post by John Lima
Hello,
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!
John
--
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
.
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/groups/opt_out.
--
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-users+***@googlegroups.com.
To post to this group, send email to mongoose-***@googlegroups.com.
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/groups/opt_out.
Sergey Lyubka
2013-10-30 23:10:30 UTC
Permalink
I think people have done what you're asking about:

https://github.com/cesanta/mongoose/issues/195
https://groups.google.com/forum/#!topic/mongoose-users/6khOpJQeqSI
Post by John Lima
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.
Thanks!
Post by Sergey Lyubka
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?
Post by John Lima
Hello,
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!
John
--
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
Visit this group at http://groups.google.com/**group/mongoose-users<http://groups.google.com/group/mongoose-users>
.
For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
.
--
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
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/groups/opt_out.
--
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-users+***@googlegroups.com.
To post to this group, send email to mongoose-***@googlegroups.com.
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/groups/opt_out.
Loading...