Skip to content

fix(ocpp-wamp): report a failed connection as a connection failure - #151

Open
juherr wants to merge 1 commit into
IZIVIA:devfrom
juherr:juherr/ocpp-toolkit-issue-148
Open

juherr wants to merge 1 commit into
IZIVIA:devfrom
juherr:juherr/ocpp-toolkit-issue-148

Conversation

@juherr

@juherr juherr commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

OkHttpOcppWampClient.onFailure reset the state to DISCONNECTED before testing it against CONNECTING, so a failure while connecting was reported as onConnectionLost instead of onConnectionFailure. The previous state is now captured first, as onClosing already does, and onConnectionFailure is forwarded to the connect() listener before connect() is released (it still throws the IOException). Behaviour change: with auto-reconnect (the newClient default), a failed attempt no longer emits a spurious onConnectionLost before onConnectionFailure. Two new tests against a port with no listener (direct and auto-reconnect client) fail on dev and pass with the fix; full build green (1212 tests).

Closes #148

OkHttpOcppWampClient.onFailure reset the state to DISCONNECTED before
testing it against CONNECTING, so a failure while connecting always
took the connection-lost branch. The connect() listener then received
a spurious onConnectionLost, and the auto-reconnect client reported
every failed attempt as a connection lost followed by a connection
failure.

Capture the previous state first, as onClosing already does, and
forward onConnectionFailure to the connect() listener before releasing
connect(), whose cleanup drops that listener. connect() still throws
the IOException.

Closes IZIVIA#148
@sonarqubecloud

sonarqubecloud Bot commented Nov 8, 2026

Copy link
Copy Markdown

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.

fix(ocpp-wamp): OkHttp client reports a connection failure as a connection lost

1 participant