Enhance WebSocket connection management and signer implementation
- Added a pong handler to extend the read deadline upon receiving PONG messages in WebSocket connections, improving connection stability. - Updated the signer implementation to serialize the x-only public key to 32 bytes, ensuring compatibility with the internal format. - Refactored tests to utilize MustNew() for signer initialization, enhancing error handling during key generation. - Bumped version to v0.25.1 to reflect these updates.
This commit is contained in:
@@ -76,6 +76,12 @@ whitelist:
|
||||
// Set initial read deadline - pong handler will extend it when pongs are received
|
||||
conn.SetReadDeadline(time.Now().Add(DefaultPongWait))
|
||||
|
||||
// Add pong handler to extend read deadline when client responds to pings
|
||||
conn.SetPongHandler(func(string) error {
|
||||
log.T.F("received PONG from %s, extending read deadline", remote)
|
||||
return conn.SetReadDeadline(time.Now().Add(DefaultPongWait))
|
||||
})
|
||||
|
||||
defer conn.Close()
|
||||
listener := &Listener{
|
||||
ctx: ctx,
|
||||
@@ -231,6 +237,10 @@ func (s *Server) Pinger(
|
||||
defer func() {
|
||||
log.D.F("pinger shutting down")
|
||||
ticker.Stop()
|
||||
// Recover from panic if channel is closed
|
||||
if r := recover(); r != nil {
|
||||
log.D.F("pinger recovered from panic (channel likely closed): %v", r)
|
||||
}
|
||||
}()
|
||||
pingCount := 0
|
||||
for {
|
||||
|
||||
Reference in New Issue
Block a user