AutoPing from Javascript Client?

1,142 views
Skip to first unread message

merr...@gmail.com

unread,
Jan 13, 2016, 4:15:59 AM1/13/16
to Autobahn
I have auto_ping_interval set on Crossbar which seems to be working as expected.  However the Javascript client does not see a loss of connection (eg pull the cable) in a timely manner.  I realize TCP doesn't allow this to be directly detected and that pings must be used.  I see three possible solutions but can only figure out how to accomplish the least prefered:

1)  Ideally the client could detect the missing ping from the server and close the connection (after a suitable timeout allowance).  I couldn't find any support to do this automatically or manually (ie the server ping doesn't seem to be exposed on the client?).

2)  The client could generate and auto_ping just like the server.  The websocket seems to support this but I couldn't figure out how to trigger it at the WAMP connection level.  This also has the disadvantage of generating twice the pings.

3)  Create an application level "ping" by periodically calling a heartbeat function that publishes to a dummy topic.  This seems kind of hackish but it is the one approach I've been able to implement.

-b

Tobias Oberstein

unread,
Jan 13, 2016, 4:16:16 PM1/13/16
to autob...@googlegroups.com
What exactly does "JavaScript Client" refer to?

AutobahnJS?

Browser or NodeJS?
> --
> You received this message because you are subscribed to the Google
> Groups "Autobahn" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to autobahnws+...@googlegroups.com
> <mailto:autobahnws+...@googlegroups.com>.
> To post to this group, send email to autob...@googlegroups.com
> <mailto:autob...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autobahnws/bb975b16-e90d-42bc-b391-818bf9ea21cf%40googlegroups.com
> <https://groups.google.com/d/msgid/autobahnws/bb975b16-e90d-42bc-b391-818bf9ea21cf%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

merr...@gmail.com

unread,
Jan 13, 2016, 5:45:59 PM1/13/16
to Autobahn
Correct.  AutobahnJS running through the browser (Chrome)

Tobias Oberstein

unread,
Jan 13, 2016, 6:19:07 PM1/13/16
to autob...@googlegroups.com
Am 13.01.2016 um 23:45 schrieb merr...@gmail.com:
> Correct. AutobahnJS running through the browser (Chrome)

The WebSocket API in browsers does not expose WebSocket ping/pongs to
JS. Neither the reception of pings, nor the sending of pings.

You simply don't have any influence on that.

The WebSocket protocol spec requires a conforming WebSocket client to
respond to pings with pongs (slightly simplified).

At least at some point, IE actively sent WS pings. Not sure if that is
still true. But you can't control is from JS. And other browsers just
sit still.

So both 1) and 2) in your question are technically not possible as of today.

That leaves option 3) ..

We once had heartbeats (ping/pong) at the WAMP protocol level, but
decided that it "mixes layers".

Heartbeating is a transport thing, and should be handled at that level.
The fact that the browser WS API does not expose controls is a bug in
that API.

Cheers,
/Tobias


>
> On Wednesday, January 13, 2016 at 4:16:16 PM UTC-5, Tobias Oberstein wrote:
>
> What exactly does "JavaScript Client" refer to?
>
> AutobahnJS?
>
> Browser or NodeJS?
>
> > an email to autobahnws+...@googlegroups.com <javascript:>
> > <mailto:autobahnws+...@googlegroups.com <javascript:>>.
> > To post to this group, send email to autob...@googlegroups.com
> <javascript:>
> > <mailto:autob...@googlegroups.com <javascript:>>.
> <https://groups.google.com/d/msgid/autobahnws/bb975b16-e90d-42bc-b391-818bf9ea21cf%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Autobahn" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to autobahnws+...@googlegroups.com
> <mailto:autobahnws+...@googlegroups.com>.
> To post to this group, send email to autob...@googlegroups.com
> <mailto:autob...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autobahnws/69e1f6a9-0dc0-4255-a367-5e5a13f7630b%40googlegroups.com
> <https://groups.google.com/d/msgid/autobahnws/69e1f6a9-0dc0-4255-a367-5e5a13f7630b%40googlegroups.com?utm_medium=email&utm_source=footer>.

merr...@gmail.com

unread,
Jan 13, 2016, 6:45:11 PM1/13/16
to Autobahn
Thanks Tobias for the detailed answer.  So something like this is currently the best/only way for a client to detect a failed Websocket from the client end in a timely manner?

```
function heartbeat() {
  connection.session.publish("fake.topic", ['Hello, world!'], {}, {})
  setTimeout(heartbeat, 10000);
}
heartbeat()
```

>      > <mailto:autobahnws+unsub...@googlegroups.com <javascript:>>.
>      > To post to this group, send email to autob...@googlegroups.com
>     <javascript:>
>      > <mailto:autob...@googlegroups.com <javascript:>>.
>      > To view this discussion on the web visit
>      >
>     https://groups.google.com/d/msgid/autobahnws/bb975b16-e90d-42bc-b391-818bf9ea21cf%40googlegroups.com
>     <https://groups.google.com/d/msgid/autobahnws/bb975b16-e90d-42bc-b391-818bf9ea21cf%40googlegroups.com>
>
>      >
>     <https://groups.google.com/d/msgid/autobahnws/bb975b16-e90d-42bc-b391-818bf9ea21cf%40googlegroups.com?utm_medium=email&utm_source=footer
>     <https://groups.google.com/d/msgid/autobahnws/bb975b16-e90d-42bc-b391-818bf9ea21cf%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>      > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Autobahn" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to autobahnws+...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages