Skip to content
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

The moquette server closes the connection #864

Open
Agoni-sudo opened this issue Oct 30, 2024 · 4 comments
Open

The moquette server closes the connection #864

Agoni-sudo opened this issue Oct 30, 2024 · 4 comments

Comments

@Agoni-sudo
Copy link

The paho-client library repeatedly disconnects and connects when creating a client connection to moquette. This does not happen when connecting with the mqttx test tool but drops and reconnects every 8 minutes or so

2024-10-30 14:16:06.387 INFO 30908 --- [tLoopGroup-3-18] i.m.broker.metrics.MQTTMessageLogger : C->B CONNECT
2024-10-30 14:16:06.388 INFO 30908 --- [pool-2-thread-1] c.b.mqttImp.SafetyInterceptHandler : 连接:io.moquette.interception.messages.InterceptConnectMessage@40bea6d2
2024-10-30 14:16:06.395 INFO 30908 --- [tLoopGroup-3-18] i.m.broker.metrics.MQTTMessageLogger : C->B SUBSCRIBE <mqtt_fx0604> to topics [MqttTopicSubscription[topicFilter=Mosquitto_bridge, option=SubscriptionOption[qos=AT_MOST_ONCE, noLocal=false, retainAsPublished=false, retainHandling=SEND_AT_SUBSCRIBE]]]
2024-10-30 14:16:06.395 INFO 30908 --- [tLoopGroup-3-18] i.m.broker.metrics.MQTTMessageLogger : C<-B SUBACK <mqtt_fx0604> packetID <1>, grantedQoses [0]
2024-10-30 14:16:06.396 INFO 30908 --- [pool-2-thread-1] c.b.mqttImp.SafetyInterceptHandler : 客户端 mqtt_fx0604 订阅主题:Mosquitto_bridge
2024-10-30 14:16:06.753 INFO 30908 --- [tLoopGroup-3-19] i.m.broker.metrics.MQTTMessageLogger : C->B CONNECT
2024-10-30 14:16:06.756 INFO 30908 --- [tLoopGroup-3-18] i.m.broker.metrics.MQTTMessageLogger : Channel Inactive
2024-10-30 14:16:06.756 INFO 30908 --- [pool-2-thread-1] c.b.mqttImp.SafetyInterceptHandler : 连接:io.moquette.interception.messages.InterceptConnectMessage@570486df
2024-10-30 14:16:06.756 INFO 30908 --- [tLoopGroup-3-18] io.moquette.broker.MQTTConnection : Notifying connection lost event
2024-10-30 14:16:06.756 INFO 30908 --- [pool-2-thread-1] c.b.mqttImp.SafetyInterceptHandler : 连接丢失:mqtt_fx0604
2024-10-30 14:16:06.757 INFO 30908 --- [tLoopGroup-3-19] i.m.broker.metrics.MQTTMessageLogger : C->B SUBSCRIBE <mqtt_fx0604> to topics [MqttTopicSubscription[topicFilter=online01Topic, option=SubscriptionOption[qos=AT_LEAST_ONCE, noLocal=false, retainAsPublished=false, retainHandling=SEND_AT_SUBSCRIBE]]]
2024-10-30 14:16:06.757 INFO 30908 --- [tLoopGroup-3-19] i.m.broker.metrics.MQTTMessageLogger : C<-B SUBACK <mqtt_fx0604> packetID <1>, grantedQoses [1]
2024-10-30 14:16:06.757 INFO 30908 --- [pool-2-thread-1] c.b.mqttImp.SafetyInterceptHandler : 客户端 mqtt_fx0604 订阅主题:online01Topic
2024-10-30 14:16:06.760 INFO 30908 --- [tLoopGroup-3-19] i.m.broker.metrics.MQTTMessageLogger : C<-B PUBACK <mqtt_fx0604> packetID <2>
2024-10-30 14:16:06.760 INFO 30908 --- [pool-2-thread-1] c.b.mqttImp.SafetyInterceptHandler : 发送数据:主题 = online01Topic, 内容 = online01
2024-10-30 14:16:07.422 INFO 30908 --- [tLoopGroup-3-19] i.m.broker.metrics.MQTTMessageLogger : C->B PUBACK <mqtt_fx0604> packetID <1>
2024-10-30 14:16:17.108 INFO 30908 --- [tLoopGroup-3-20] i.m.broker.metrics.MQTTMessageLogger : C->B CONNECT
2024-10-30 14:16:17.110 INFO 30908 --- [tLoopGroup-3-19] i.m.broker.metrics.MQTTMessageLogger : Channel Inactive
2024-10-30 14:16:17.111 INFO 30908 --- [tLoopGroup-3-19] io.moquette.broker.MQTTConnection : Notifying connection lost event
2024-10-30 14:16:17.111 INFO 30908 --- [pool-2-thread-1] c.b.mqttImp.SafetyInterceptHandler : 连接:io.moquette.interception.messages.InterceptConnectMessage@73dea4e
2024-10-30 14:16:17.111 INFO 30908 --- [pool-2-thread-1] c.b.mqttImp.SafetyInterceptHandler : 连接丢失:mqtt_fx0604
2024-10-30 14:16:17.111 INFO 30908 --- [tLoopGroup-3-20] i.m.broker.metrics.MQTTMessageLogger : C->B SUBSCRIBE <mqtt_fx0604> to topics [MqttTopicSubscription[topicFilter=Mosquitto_bridge, option=SubscriptionOption[qos=AT_MOST_ONCE, noLocal=false, retainAsPublished=false, retainHandling=SEND_AT_SUBSCRIBE]]]
2024-10-30 14:16:17.111 INFO 30908 --- [tLoopGroup-3-20] i.m.broker.metrics.MQTTMessageLogger : C<-B SUBACK <mqtt_fx0604> packetID <1>, grantedQoses [0]
2024-10-30 14:16:17.111 INFO 30908 --- [pool-2-thread-1] c.b.mqttImp.SafetyInterceptHandler : 客户端 mqtt_fx0604 订阅主题:Mosquitto_bridge

@hylkevds
Copy link
Collaborator

Given the line

2024-10-30 14:16:17.110 INFO 30908 --- [tLoopGroup-3-19] i.m.broker.metrics.MQTTMessageLogger : Channel Inactive

I'm guessing that your connection is timing out. Can you try turning on keep-alive messages, or increasing the keep-alive frequency?

@Agoni-sudo
Copy link
Author

给定线路

2024-10-30 14:16:17.110 INFO 30908 --- [tLoopGroup-3-19] i.m.broker.metrics.MQTTMessageLogger : Channel Inactive

我猜您的连接超时了。您可以尝试打开保持活动消息或提高保持活动频率吗?

public MqttConnectOptions mqttConnectOptions() {
MqttConnectOptions options = new MqttConnectOptions();
options.setServerURIs(new String[]{hostUrl});
//options.setUserName("");
// options.setPassword("".toCharArray());
options.setConnectionTimeout(20);
options.setKeepAliveInterval(30);
options.setWill(willTopic, willData, 2, false); // 设置遗嘱消息
return options;
}
Is it keeplive of mqtt? On the client side, I set the heartbeat rate to 30s, but it still disconnects after a period of time

@Yunustt
Copy link

Yunustt commented Nov 7, 2024

You can view this method initializeKeepAliveTimeout

@Yunustt
Copy link

Yunustt commented Nov 7, 2024

The keeplive in the broker comes from the MQTT message

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

No branches or pull requests

3 participants