Socket.io-client: Document 'ping' and 'pong' events in http://socket.io/docs

Created on 13 Nov 2016  ·  10Comments  ·  Source: socketio/socket.io-client

ping and pong events are undocumented in the website (socket.io/docs), potentially causing confusion when somebody tries to implement their own ping-pong system. socket.emit('pong') on the browser does not cause anything to be sent over the socket (verified with localStorage.debug = '*';), maybe socket.emit('ping') should also report an error letting the developer know it's a reserved keyword.

From README.md:

- `ping`. Fired when a ping packet is written out to the server.
- `pong`. Fired when a pong is received from the server.
    Parameters:
    - `Number` number of ms elapsed since `ping` packet (i.e.: latency)."

Most helpful comment

Is ping/pong not some real basic shit in networking? why the hell would they not be documented? There are ping and pong events sent back and fourth between the server and client automatically (upon socket connection)? If so, how do i look at these events and their timestamps to measure latency?

All 10 comments

Agreed!
I know one must read the fabulous manual, but I still managed to lost a couple of hours (and hair) figuring out why the hell my code wasn't working.
Totally my fault, but I would have liked it a lot if I was thrown some warning saying "Those events are reserved, try something else".

PR is welcome, as usual!

I already considered that, but I failed to find a repository that contains the website source. Maybe I'm just incompetent or was too tired, can you point me to it?

I just started looking at this (see here) but this comes with a need of something like a verbose parameter. Plus I'm pretty sure this is also triggered by those "internal" events. And finally console.warn.calledWith() does not exist in expect.
Still need some work ...

Closing due to inactivity, please reopen if needed.

It's hard to know if the issue was fixed or not, due to #1054 (the page renders nothing currently).

Is ping/pong not some real basic shit in networking? why the hell would they not be documented? There are ping and pong events sent back and fourth between the server and client automatically (upon socket connection)? If so, how do i look at these events and their timestamps to measure latency?

Can we reopen this, I agree with ForgeableSum. We should have more documentation.

Well it's already documented https://github.com/socketio/socket.io-client/blob/master/docs/API.md#event-ping-1 , I was struggling for hours trying to receive data from a custom ping event sent by my client, it seems that you can't override this event. 😅

Ugh. I just burnt loads of time here. RTFM.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BorntraegerMarc picture BorntraegerMarc  ·  4Comments

patrickbussmann picture patrickbussmann  ·  6Comments

catamphetamine picture catamphetamine  ·  3Comments

zappfinger picture zappfinger  ·  5Comments

ahadcove picture ahadcove  ·  7Comments