提交 6ca4b983 authored 作者: wangqiang's avatar wangqiang

mqtt连不上的时候 启动优化

上级 c02c9795
......@@ -568,16 +568,17 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall
log.debug("try connect client");
connectTbClient();
//tbClient.on(DEVICE_ATTRIBUTES_TOPIC, this).await(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS);
tbClient.on(DEVICE_GET_ATTRIBUTES_RESPONSE_PLUS_TOPIC, this).await(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS);
tbClient.on(DEVICE_GET_ATTRIBUTES_RESPONSE_TOPIC, this).await(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS);
tbClient.on(DEVICE_RPC_TOPIC, this).await(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS);
byte[] msgData = toBytes(newNode().put("sharedKeys", "configuration"));
persistMessage(DEVICE_GET_ATTRIBUTES_REQUEST_TOPIC, msgIdSeq.incrementAndGet(), msgData,
null,
error -> log.warn("Error getiing attributes", error));
if (tbClient.isConnected()) {
//tbClient.on(DEVICE_ATTRIBUTES_TOPIC, this).await(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS);
tbClient.on(DEVICE_GET_ATTRIBUTES_RESPONSE_PLUS_TOPIC, this).await(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS);
tbClient.on(DEVICE_GET_ATTRIBUTES_RESPONSE_TOPIC, this).await(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS);
tbClient.on(DEVICE_RPC_TOPIC, this).await(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS);
byte[] msgData = toBytes(newNode().put("sharedKeys", "configuration"));
persistMessage(DEVICE_GET_ATTRIBUTES_REQUEST_TOPIC, msgIdSeq.incrementAndGet(), msgData,
null,
error -> log.warn("Error getiing attributes", error));
}
return tbClient;
} catch (InterruptedException e) {
log.error(e.getMessage(), e);
......@@ -603,7 +604,11 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall
}
});
try {
connectResult.get(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS);
MqttConnectResult mqttConnectResult = connectResult.get(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS);
if (!mqttConnectResult.isSuccess()) {
log.error("Unable to sucess connect to mqtt server try again!");
tbClient.disconnect();
}
} catch (TimeoutException e) {
log.error("Unable to connect to mqtt server try again!");
String message = "Unable to connect to Priusisiot. Connection timed out after [" + connection.getConnectionTimeout() + "] milliseconds";
......
......@@ -25,7 +25,7 @@ core:
connection:
host: "${PC_HOST:127.0.0.1}"
port: "${PC_PORT:1884}"
retryInterval: 3000
retryInterval: 6000
maxInFlight: 1000
security:
apiByMac: "${PC_API_BY_MAC:true}"
......
......@@ -4,7 +4,7 @@
#define MyAppName "阿普奇检测客户端"
#define MyAppVersion "V1.0"
#define MyAppPublisher "阿普奇"
#define MyAppURL "https://www.apq.com/"
#define MyAppURL "https://www.apq.com/"
#define MyAppDirName "apq-client"
#define MyAppEnName "apq-client"
#define MyAppExeName "apq-client.exe"
......
......@@ -8,6 +8,16 @@ net stop apq-client-service
@ECHO Uninstalling apq-client-service ...
"%~dp0apq-client-service.exe" uninstall
@ECHO Stopping apq-other-service ...
net stop apq-control-service
net stop apq-info-service
net stop apq-register-service
@ECHO Uninstalling apq-other-service ...
sc delete apq-control-service
sc delete apq-info-service
sc delete apq-register-service
@ECHO DONE.
:END
\ No newline at end of file
......@@ -2,11 +2,16 @@
setlocal ENABLEEXTENSIONS
@ECHO Installing apq-client ...
@ECHO Installing apq-client-service ...
"%~dp0apq-client-service.exe" install
@ECHO running apq-client ...
@ECHO running apq-client-service ...
"%~dp0apq-client-service.exe" start
@ECHO running apq-other-service ...
net start apq-control-service
net start apq-info-service
net start apq-register-service
@ECHO DONE.
:END
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
@ECHO OFF
cd /d "%~dp0"
setlocal enabledelayedexpansion
@ECHO Stopping apq-client-service ...
net stop apq-client-service
@ECHO Uninstalling apq-client-service ...
"%~dp0apq-client-service.exe" uninstall
@ECHO Stopping apq-other-service ...
net stop apq-control-service
net stop apq-info-service
net stop apq-register-service
@ECHO Uninstalling apq-other-service ...
sc delete apq-control-service
sc delete apq-info-service
sc delete apq-register-service
for /F "TOKENS=1,2,*" %%b in ('tasklist /FI "IMAGENAME eq apq.exe"') do TASKKILL /F /PID %%b
taskkill -f -t -im %MyPID%
@ECHO DONE.
for /F "TOKENS=1,2,*" %%a in ('jps -m ^| findstr apq-pc-client') do set SPID=%%a
TASKKILL /F /PID %SPID%
:END
\ No newline at end of file
echo stop apq client service
exit
\ No newline at end of file
@ECHO OFF
cd /d "%~dp0"
::start xx.exe
setlocal enabledelayedexpansion
setlocal ENABLEEXTENSIONS
for /F "TOKENS=1,2,*" %%b in ('tasklist /FI "IMAGENAME eq apq.exe"') do TASKKILL /F /PID %%b
::taskkill -f -t -im %MyPID%
@ECHO Installing apq-client-service ...
"%~dp0apq-client-service.exe" install
@ECHO running apq-client-service ...
"%~dp0apq-client-service.exe" start
for /F "TOKENS=1,2,*" %%a in ('jps -m ^| findstr apq-pc-client') do set SPID=%%a
TASKKILL /F /PID %SPID%
@ECHO running apq-other-service ...
net start apq-control-service
net start apq-info-service
net start apq-register-service
@ECHO DONE.
:END
\ No newline at end of file
start ..\jre\bin\apq-client -Xms256m -Xmx256m -Dfile.encoding=utf-8 -jar "%~dp0\apq-pc-client-0.0.1-SNAPSHOT-boot.jar"
echo start apq client service
exit
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论