Skip to content

Conversation

artembilan
Copy link
Member

Fixes #3959

The MqttCallback.disconnected(MqttDisconnectResponse) in Paho v5 client is also called when server initiates a disconnection.
In this case that MqttDisconnectResponse does not have a cause value

  • Modify MqttConnectionFailedEvent to make a cause property optional
  • Fix Mqttv5PahoMessageDrivenChannelAdapter & Mqttv5PahoMessageHandler to not check for cause, but emit an MqttConnectionFailedEvent for any disconnected() calls

Unfortunately current Paho v3 client does not call connectionLost() for normal disconnections and we cannot react for this callback with an MqttConnectionFailedEvent

Cherry-pick to 5.5.x

Fixes spring-projects#3959

The `MqttCallback.disconnected(MqttDisconnectResponse)` in Paho v5 client is also
called when server initiates a disconnection.
In this case that `MqttDisconnectResponse` does not have a `cause` value

* Modify `MqttConnectionFailedEvent` to make a `cause` property optional
* Fix `Mqttv5PahoMessageDrivenChannelAdapter` & `Mqttv5PahoMessageHandler`
to not check for `cause`, but emit an `MqttConnectionFailedEvent` for any `disconnected()` calls

Unfortunately current Paho v3 client does not call `connectionLost()` for normal disconnections
and we cannot react for this callback with an `MqttConnectionFailedEvent`

**Cherry-pick to `5.5.x`**
Co-authored-by: Gary Russell <[email protected]>
@garyrussell garyrussell merged commit 6fd4fd3 into spring-projects:main Dec 7, 2022
garyrussell added a commit that referenced this pull request Dec 7, 2022
* GH-3959: MqttConFailedEvent for normal disconnect

Fixes #3959

The `MqttCallback.disconnected(MqttDisconnectResponse)` in Paho v5 client is also
called when server initiates a disconnection.
In this case that `MqttDisconnectResponse` does not have a `cause` value

* Modify `MqttConnectionFailedEvent` to make a `cause` property optional
* Fix `Mqttv5PahoMessageDrivenChannelAdapter` & `Mqttv5PahoMessageHandler`
to not check for `cause`, but emit an `MqttConnectionFailedEvent` for any `disconnected()` calls

Unfortunately current Paho v3 client does not call `connectionLost()` for normal disconnections
and we cannot react for this callback with an `MqttConnectionFailedEvent`

**Cherry-pick to `5.5.x`**

* Fix language in doc

Co-authored-by: Gary Russell <[email protected]>

Co-authored-by: Gary Russell <[email protected]>
@garyrussell
Copy link
Contributor

...and cherry-picked as 280eb29

@artembilan artembilan deleted the GH-3959 branch December 7, 2022 14:20
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.

MQTTv5: Disconnect message does not trigger MqttConnectionFailedEvent

2 participants