Heart beat system

80 views
Skip to first unread message

Gauthier Brin

unread,
Jan 11, 2024, 11:25:45 AMJan 11
to noVNC
Hi,
I would  like to know if it's possible to determine if the noVnc is sending message in the web Socket or if it's ready ? could be something like a heart beat or ping pong  system?

One possible use case could be:
- if the user has lost his network connection, we would like do display a reconnecting screen until he get back his internet connection and the websocket is ready.

I didn't find any event or function that could help me in the documentation.
The only thing I could do, it's to recreate a new VNC and listen the `connect` event.


do you have another solution or ideas ?

Pierre Ossman

unread,
Jan 12, 2024, 1:31:58 AMJan 12
to no...@googlegroups.com, Gauthier Brin
On 11/01/2024 17:17, Gauthier Brin wrote:
> Hi,
> I would like to know if it's possible to determine if the noVnc is sending
> message in the web Socket or if it's ready ? could be something like a
> heart beat or ping pong system?
>

WebSockets have a ping feature, but I don't think it's reachable from
JavaScript. So any such system would need to be built at the RFB level.
Which means you need to do it in the RFB object, not outside of it.

VNC/RFB doesn't have a dedicated ping system, so you would need to get
creative. The fence message could probably be used, but not all servers
support that.

> One possible use case could be:
> - if the user has lost his network connection, we would like do display a
> reconnecting screen until he get back his internet connection and the
> websocket is ready.
>

That is definitely an interesting use case. It's something we've
discussed here as well.

I don't think it's well behaved to spam pings constantly, but you could
likely combine it with user interactions. E.g. if the user uses the
mouse or keyboard, but we don't get anything back from the server within
a timeout, then send a ping to make sure we still have contact.

Regards
--
Pierre Ossman Software Development
Cendio AB http://cendio.com
Teknikringen 8 http://twitter.com/ThinLinc
583 30 Linköping http://facebook.com/ThinLinc
Phone: +46-13-214600

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

Gauthier Brin

unread,
Jan 12, 2024, 2:40:41 AMJan 12
to noVNC
Thanks for your answers. It's really helpful.

But what do you mean by 'fence message' ?

Pierre Ossman

unread,
Jan 12, 2024, 3:11:08 AMJan 12
to no...@googlegroups.com, Gauthier Brin
On 12/01/2024 08:40, Gauthier Brin wrote:
> Thanks for your answers. It's really helpful.
>
> But what do you mean by 'fence message' ?
>

This extension:

https://github.com/rfbproto/rfbproto/blob/master/rfbproto.rst#clientfence

Regards
--
Pierre Ossman Software Development
Cendio AB https://cendio.com
Teknikringen 8 https://twitter.com/ThinLinc
583 30 Linköping https://facebook.com/ThinLinc

Cary Lewis

unread,
Jan 12, 2024, 7:19:21 AMJan 12
to no...@googlegroups.com
Why not spin up a new websocket to implement the heartbeat?

> On Jan 12, 2024, at 3:11 AM, 'Pierre Ossman' via noVNC <no...@googlegroups.com> wrote:
> --
> You received this message because you are subscribed to the Google Groups "noVNC" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to novnc+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/novnc/555110c5-43bb-4c70-8789-a03e0c6792fc%40cendio.se.

Pierre Ossman

unread,
Jan 12, 2024, 7:23:10 AMJan 12
to no...@googlegroups.com, Cary Lewis
On 12/01/2024 13:19, Cary Lewis wrote:
> Why not spin up a new websocket to implement the heartbeat?
>

That would be outside the scope of noVNC. We only implement the VNC
protocol. So we can only what's defined in that protocol, and what
WebSockets directly provide.

A second WebSocket would also not monitor the active connection
directly. So it would not be an equally robust method.

Stéphane Ancelot

unread,
Jun 26, 2024, 6:04:50 AMJun 26
to noVNC
I had similar need , because I can not detect broken connection.

I am using xvncserver, that is able to send a ping 1x1 framebuffer update every n seconds.

I created a pull request , it seems to work fine 

ping keepalive feature by sancelot · Pull Request #1872 · novnc/noVNC (github.com)
Reply all
Reply to author
Forward
0 new messages