Skip to content

Publishing MqttConnectionFailedEvent on reconnection in MqttPahoMessageHandler #3215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
murphy-25 opened this issue Mar 15, 2020 · 1 comment · Fixed by #3220
Closed

Publishing MqttConnectionFailedEvent on reconnection in MqttPahoMessageHandler #3215

murphy-25 opened this issue Mar 15, 2020 · 1 comment · Fixed by #3220

Comments

@murphy-25
Copy link

We use MQTT server with Keycloak requiring us to generate a token with Keycloak before we start a connection between our spring boot application and MQTT. On occasions for whatever reason that connection gets dropped, current behaviour means it will try to reconnect when the next message is published. When this occurs the existing connection details are used which potentially contains an expired token.

There doesn't seem to be to way that we can alter the connection options or at least have some flexibility when the connection is lost. My proposal includes something that has already been implemented in the MqttPahoMessageDrivenChannelAdapter class where a MqttConnectionFailedEvent is published. The same would be published on the producer side in the MqttPahoMessageHandler class enabling us to have some sort of flexibility in dealing with lost connection issues.

@artembilan
Copy link
Member

I find this as a valid request as long as the connectionLost(Throwable cause) is called for an expired token reason, so you really can catch that MqttConnectionFailedEvent and correct MqttConnectOptions on the DefaultMqttPahoClientFactory.

If this is what you expect, feel free to provide a fix via contribution: https://github.com/spring-projects/spring-integration/blob/master/CONTRIBUTING.adoc

I even don't find this as a breaking change and we can back-port a fix into 5.2.x supported branch.

Thanks

@artembilan artembilan added this to the 5.3 RC1 milestone Mar 16, 2020
@garyrussell garyrussell self-assigned this Mar 17, 2020
garyrussell added a commit to garyrussell/spring-integration that referenced this issue Mar 17, 2020
artembilan pushed a commit that referenced this issue Mar 17, 2020
Resolves #3215

* Add docs; publish an event for an initial connection failure too.

**Cherry-pick to 5.2.x**
artembilan pushed a commit that referenced this issue Mar 17, 2020
Resolves #3215

* Add docs; publish an event for an initial connection failure too.

**Cherry-pick to 5.2.x**
@artembilan artembilan modified the milestones: 5.3 RC1, 5.3.M4 Mar 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants