经常出现等待来自服务器的响应时超时, 这个是什么问题呢?

环境信息

  • EMQ X 版本:4.3.2
  • 操作系统及版本:CentOS7
  • 其他

问题描述

客户端经常出现服务器响应超时。

org.eclipse.paho.client.mqttv3.MqttException: 等待来自服务器的响应时超时
	at org.eclipse.paho.client.mqttv3.internal.Token.waitForCompletion(Token.java:112)
	at org.eclipse.paho.client.mqttv3.MqttToken.waitForCompletion(MqttToken.java:67)
	at org.eclipse.paho.client.mqttv3.MqttClient.connect(MqttClient.java:333)
	at org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter.connectAndSubscribe(MqttPahoMessageDrivenChannelAdapter.java:245)
	at org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter.lambda$scheduleReconnect$0(MqttPahoMessageDrivenChannelAdapter.java:308)
	at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

2021-08-06 09:35:58.159 ERROR 7186 --- [ask-scheduler-5] .m.i.MqttPahoMessageDrivenChannelAdapter : Error connecting or subscribing to [openDoorProd]

org.eclipse.paho.client.mqttv3.MqttException: 等待来自服务器的响应时超时
	at org.eclipse.paho.client.mqttv3.internal.Token.waitForCompletion(Token.java:112)
	at org.eclipse.paho.client.mqttv3.MqttToken.waitForCompletion(MqttToken.java:67)
	at org.eclipse.paho.client.mqttv3.MqttClient.connect(MqttClient.java:333)
	at org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter.connectAndSubscribe(MqttPahoMessageDrivenChannelAdapter.java:245)
	at org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter.lambda$scheduleReconnect$0(MqttPahoMessageDrivenChannelAdapter.java:308)
	at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

您好,这个客户端日志只能知道Mqtt Client连接没有成功,具体原因麻烦您提供下对应的服务器日志

我是用docker运行的,在哪里可以看到日志呢?谢谢!

您好,抱歉没有及时回复您,你可以通过 docker logs 命令来查看 emqx 日志。


像这种是不是会影响?

DOCKER日志滚得很快,每天一堆这些信息,有没有什么好的办法来解决呢?是不是压力过大造成的?

2021-08-15 00:02:03.730 [task-scheduler-3] ERROR o.s.i.m.i.MqttPahoMessageDrivenChannelAdapter - Error connecting or subscribing to [openDoorProd]

org.eclipse.paho.client.mqttv3.MqttException: 等待来自服务器的响应时超时

at org.eclipse.paho.client.mqttv3.internal.Token.waitForCompletion(Token.java:112)

at org.eclipse.paho.client.mqttv3.MqttToken.waitForCompletion(MqttToken.java:67)

at org.eclipse.paho.client.mqttv3.MqttClient.subscribe(MqttClient.java:432)

at org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter.connectAndSubscribe(MqttPahoMessageDrivenChannelAdapter.java:248)

at org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter.lambda$scheduleReconnect$0(MqttPahoMessageDrivenChannelAdapter.java:308)

at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at java.lang.Thread.run(Thread.java:748)

2021-08-15 00:02:15.204 [MQTT Rec: slfroomprod_345_512_1_inbound] ERROR o.s.i.m.i.MqttPahoMessageDrivenChannelAdapter - Lost connection: 已断开连接; retrying...

2021-08-15 00:02:15.204 [task-scheduler-3] ERROR o.s.i.m.i.MqttPahoMessageDrivenChannelAdapter - Exception while connecting and subscribing

org.eclipse.paho.client.mqttv3.MqttException: 等待来自服务器的响应时超时

at org.eclipse.paho.client.mqttv3.internal.Token.waitForCompletion(Token.java:112)

at org.eclipse.paho.client.mqttv3.MqttToken.waitForCompletion(MqttToken.java:67)

at org.eclipse.paho.client.mqttv3.MqttClient.subscribe(MqttClient.java:432)

at org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter.connectAndSubscribe(MqttPahoMessageDrivenChannelAdapter.java:248)

at org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter.lambda$scheduleReconnect$0(MqttPahoMessageDrivenChannelAdapter.java:308)

at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at java.lang.Thread.run(Thread.java:748)

2021-08-15 00:10:25.238 [MQTT Ping: slfroomprod_345_512_1_inbound] ERROR o.eclipse.paho.client.mqttv3.internal.ClientState - slfroomprod_345_512_1_inbound: Timed out as no activity, keepAlive=20,000 lastOutboundActivity=1,628,957,405,237 lastInboundActivity=1,628,957,400,717 time=1,628,957,425,237 lastPing=1,628,957,405,237

2021-08-15 00:10:25.241 [MQTT Ping: slfroomprod_345_512_1_inbound] ERROR o.s.i.m.i.MqttPahoMessageDrivenChannelAdapter - Lost connection: 等待来自服务器的响应时超时; retrying...

这个日志是消息队列满了然后队列中最早的消息就被丢弃了,出现的原因通常是订阅端消费能力不够。建议改进订阅端处理代码,或者尝试使用共享订阅。

是不是“等待来自服务器的响应时超时”也和订阅端处理问题有关?

请问一下,broker版本可以支持1000个客户端,3000个主题的使用吗?