我正在遵循Eclipse Hono 入门指南并使用沙盒环境。
我打开 git bash 终端并使用此命令启动设备以接收命令:
mosquitto_sub -v -h $MQTT_ADAPTER_IP -u $MY_DEVICE@$MY_TENANT -P $MY_PWD -t command/+/+/req/#
我打开了另一个 git bash 终端,并使用此命令让应用程序客户端向设备发送命令:
java -jar hono-cli-*-exec.jar --hono.client.host=$AMQP_NETWORK_IP --hono.client.port=15672 --hono.client.username=consumer@HONO --hono.client.password=verysecret --tenant.id=$MY_TENANT --device.id=$MY_DEVICE --spring.profiles.active=command
但是当我使用上面的命令时,我得到了这个异常:
21:41:45.504 [main] INFO org.eclipse.hono.cli.Application - Starting Application v1.3.0 on DESKTOP-4SV0QNN with PID 9768 (C:\Users\HP\hono-cli-1.3.0-exec.jar started by HP in C:\Users\HP)
21:41:45.509 [main] INFO org.eclipse.hono.cli.Application - The following profiles are active: command
21:41:47.092 [main] INFO org.eclipse.hono.cli.Application - running command line client in role(s): command
21:41:50.249 [main] INFO org.eclipse.hono.cli.Application - Started Application in 7.064 seconds (JVM running for 10.127)
21:42:17.462 [vert.x-eventloop-thread-0] INFO o.e.h.client.impl.HonoConnectionImpl - max number of attempts [5] to re-connect to server [hono.eclipseprojects.io:15672, role: unknown] have been made, giving up
21:42:17.595 [vert.x-eventloop-thread-0] INFO o.e.h.client.impl.HonoConnectionImpl - stopping connection attempt to server [hono.eclipseprojects.io:15672, role: unknown] due to terminal error
org.eclipse.hono.connection.ConnectTimeoutException: connection attempt timed out after 5000ms
at org.eclipse.hono.connection.impl.ConnectionFactoryImpl.lambda$connect$0(ConnectionFactoryImpl.java:153)
at io.vertx.core.impl.VertxImpl$InternalTimerHandler.handle(VertxImpl.java:923)
at io.vertx.core.impl.VertxImpl$InternalTimerHandler.handle(VertxImpl.java:887)
at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366)
at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:43)
at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:229)
at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:221)
at io.vertx.core.impl.VertxImpl$InternalTimerHandler.run(VertxImpl.java:913)
at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98)
at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:170)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:834)
21:42:17.602 [vert.x-eventloop-thread-0] ERROR org.eclipse.hono.cli.app.Commander - Error: failed to connect
我在应用客户端设置了环境变量MQTT_ADAPTER_IP、MY_TENANT、MY_DEVICE,在设备端设置了MY_TENANT、MY_DEVICE、MY_PWD、MQTT_ADAPTER_IP。
这是我系统中的 jdk 版本:
C:\Users\HP>java -version
java version "11.0.7" 2020-04-14 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.7+8-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.7+8-LTS, mixed mode)
请告诉我如何解决这个问题。