mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-08-19 17:16:16 +00:00
The speaker WebSocket was cycling every ~65 s because the gorilla pong handler was never set, so the 60-second read deadline in readLoop fired after each ping cycle (30 s interval + 5 s reconnect = ~65 s loop). Setting a pong handler that extends the deadline on every pong response keeps the connection alive indefinitely during quiet periods. After any (re)connect the Go server now immediately fetches current device state via HTTP, because Bose speakers do not replay WebSocket events on new connections — anything that changed during a disconnect window would otherwise stay stale until the next speaker-side event. A 30-second periodic HTTP poll per device is added as a backstop for Spotify Connect track changes that the SoundTouch API does not surface as nowPlayingUpdated WebSocket events. On the browser side, track identity (TrackID / ContentItem.Location) is added to the NowPlaying timer effect deps so the local counter resets whenever the track changes regardless of start position, and the time label is clamped to the song total to prevent "4:17 / 4:09" overruns. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>