mqtt 发送消息断开链接
出现如下错误
o.s.i.mqtt.outbound.MqttPahoMessageHandler|Lost connection; will attempt reconnect on next request
我的配置
@Bean
public MqttPahoClientFactory mqttClientFactory1() {
DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory();
MqttConnectOptions options = new MqttConnectOptions();
options.setUserName(mqttConfig.getOutbound().getUsername());
options.setPassword(mqttConfig.getOutbound().getPassword().toCharArray());
options.setServerURIs(mqttConfig.getOutbound().getUrls().split(","));
/* options.setConnectionTimeout(mqttConfig.getOptions().getConnectionTimeout());
options.setKeepAliveInterval(mqttConfig.getOptions().getKeepAliveInterval());
options.setMaxInflight((Runtime.getRuntime().availableProcessors() * 2) * 6);
options.setCleanSession(false);
options.setAutomaticReconnect(true);*/
factory.setConnectionOptions(options);
return factory;
}
@Bean
@ServiceActivator(inputChannel = "mqttOutboundChannel")
public MessageHandler mqttOutbound() {
MqttPahoMessageHandler messageHandler =
new MqttPahoMessageHandler(mqttConfig.getOutbound().getClientId(), mqttClientFactory1());
messageHandler.setAsync(true);
return messageHandler;
}
@Bean
public MessageChannel mqttOutboundChannel() {
return new DirectChannel();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论