MCPcopy
hub / github.com/nats-io/nats.go / processPingTimer

Method processPingTimer

nats.go:5774–5795  ·  view source on GitHub ↗

This will fire periodically and send a client origin ping to the server. Will also check that we have received responses from the server.

()

Source from the content-addressed store, hash-verified

5772// ping to the server. Will also check that we have received
5773// responses from the server.
5774func (nc *Conn) processPingTimer() {
5775 nc.mu.Lock()
5776
5777 if nc.status != CONNECTED {
5778 nc.mu.Unlock()
5779 return
5780 }
5781
5782 // Check for violation
5783 nc.pout++
5784 if nc.pout > nc.Opts.MaxPingsOut {
5785 nc.mu.Unlock()
5786 if shouldClose := nc.processOpErr(ErrStaleConnection, false); shouldClose {
5787 nc.close(CLOSED, true, nil)
5788 }
5789 return
5790 }
5791
5792 nc.sendPing(nil)
5793 nc.ptmr.Reset(nc.Opts.PingInterval)
5794 nc.mu.Unlock()
5795}
5796
5797// FlushTimeout allows a Flush operation to have an associated timeout.
5798func (nc *Conn) FlushTimeout(timeout time.Duration) (err error) {

Callers

nothing calls this directly

Calls 4

processOpErrMethod · 0.95
closeMethod · 0.95
sendPingMethod · 0.95
ResetMethod · 0.65

Tested by

no test coverage detected