Skip to content

hub: prevent concurrent duplicate outgoing connections to the same SKI#85

Open
andig wants to merge 2 commits into
enbility:devfrom
andig:fix/double-connection-outgoing-dedup
Open

hub: prevent concurrent duplicate outgoing connections to the same SKI#85
andig wants to merge 2 commits into
enbility:devfrom
andig:fix/double-connection-outgoing-dedup

Conversation

@andig

@andig andig commented Jun 15, 2026

Copy link
Copy Markdown

connectFoundService only dedupes outgoing dials via isSkiConnected, which becomes true after registerConnection (i.e. after the websocket dial + SHIP handshake). Two concurrent outgoing dials to the same SKI can both pass that check, both establish, and then keepThisConnection tears one down mid-discovery. Some remotes then stop answering measurement reads on the surviving connection until the whole service is restarted.

Reserve the SKI for the duration of the dial via a new connectionsInitiating set (guarded by muxCon), so a concurrent outgoing dial returns early instead of racing to a second handshake. The incoming-vs-outgoing case is still handled by keepThisConnection.

This is a real-live issue observed as a stalled EEBus meter on a Vaillant heatpump in evcc-io/evcc#30889. PR is done by Claude but lgtm.

Comment thread hub/hub_connections_client.go Outdated
@uhl uhl self-requested a review June 17, 2026 05:45
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 92.927% (-0.03%) from 92.952% — andig:fix/double-connection-outgoing-dedup into enbility:dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants