Feature idea: measure and expose socket latency

Amazing, thanks for the quick response! That clears up my logs a lot :slight_smile:

For anyone else who wants a client-only ping hook:

Hooks.Ping = {
  mounted() {
    this.timer = null
    this.ping()
  }, 
  reconnected() {
    clearTimeout(this.timer)
    this.ping()
  },
  destroyed() { 
    clearTimeout(this.timer) 
  },
  ping() {
    liveSocket.getSocket().ping(rtt => {
      this.el.innerText = `Ping: ${rtt} ms`
      this.timer = setTimeout(() => this.ping(), 1000)
    })
  }
};
1 Like