0

我正在尝试在没有容器平台的本地机器上设置 hono。我设法运行以下服务和先决条件:

  • AMQP 代理 (RabbitMQ)
  • 涌入数据库
  • Hono MQTT 适配器
  • 荣誉认证服务
  • Hono 设备注册表

当 MQTT 适配器启动时,我得到以下日志记录:

14:37:48.257 [vert.x-eventloop-thread-0] INFO  o.e.h.c.RequestResponseClientConfigProperties - loading credentials for [127.0.0.1] from [/media/data/dev/hono-config/mqtt-adapter.credentials]
14:37:48.257 [main] DEBUG o.e.h.a.m.i.Application$$EnhancerBySpringCGLIB$$e74ec218 - Waiting 20 seconds for application to start up
14:37:48.258 [vert.x-eventloop-thread-0] DEBUG o.e.h.c.impl.ConnectionFactoryImpl - connecting to AMQP 1.0 container [amqp://127.0.0.1:5672]
14:37:48.472 [vert.x-eventloop-thread-0] DEBUG o.e.hono.client.impl.HonoClientImpl - starting attempt [#1] to connect to server [127.0.0.1:5672]
14:37:48.472 [vert.x-eventloop-thread-0] DEBUG o.e.h.c.impl.ConnectionFactoryImpl - connecting to AMQP 1.0 container [amqp://127.0.0.1:5672]
14:37:48.473 [vert.x-eventloop-thread-0] DEBUG o.e.hono.client.impl.HonoClientImpl - starting attempt [#1] to connect to server [127.0.0.1:5672]
14:37:48.473 [vert.x-eventloop-thread-0] INFO  o.e.h.c.RequestResponseClientConfigProperties - loading credentials for [127.0.0.1] from [/media/data/dev/hono-config/mqtt-adapter.credentials]
14:37:48.473 [vert.x-eventloop-thread-0] DEBUG o.e.h.c.impl.ConnectionFactoryImpl - connecting to AMQP 1.0 container [amqp://127.0.0.1:5672]
14:37:48.473 [vert.x-eventloop-thread-0] DEBUG o.e.hono.client.impl.HonoClientImpl - starting attempt [#1] to connect to server [127.0.0.1:5672]
14:37:48.473 [vert.x-eventloop-thread-0] INFO  o.e.h.c.RequestResponseClientConfigProperties - loading credentials for [127.0.0.1] from [/media/data/dev/hono-config/mqtt-adapter.credentials]
14:37:48.474 [vert.x-eventloop-thread-0] DEBUG o.e.h.c.impl.ConnectionFactoryImpl - connecting to AMQP 1.0 container [amqp://127.0.0.1:5672]
14:37:48.474 [vert.x-eventloop-thread-0] DEBUG o.e.hono.client.impl.HonoClientImpl - starting attempt [#1] to connect to server [127.0.0.1:5672]
14:37:48.474 [vert.x-eventloop-thread-0] DEBUG o.e.h.c.impl.ConnectionFactoryImpl - connecting to AMQP 1.0 container [amqp://127.0.0.1:5672]
14:37:48.474 [vert.x-eventloop-thread-0] INFO  o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - limiting size of inbound message payload to 8096 bytes
14:37:48.474 [vert.x-eventloop-thread-0] WARN  o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - authentication of devices turned off
14:37:48.474 [vert.x-eventloop-thread-0] INFO  o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - Vertx native support: false
14:37:48.476 [vert.x-eventloop-thread-0] INFO  o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - Server uses secure standard port 8883
14:37:48.479 [vert.x-eventloop-thread-0] DEBUG o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - OpenSSL [available: false, supports KeyManagerFactory: false]
14:37:48.479 [vert.x-eventloop-thread-0] INFO  o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - using JDK's default SSL engine
14:37:48.480 [vert.x-eventloop-thread-0] INFO  o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - enabling secure protocol [TLSv1.2]
14:37:48.530 [vert.x-eventloop-thread-0] INFO  o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - MQTT server running on 0.0.0.0:8883
14:37:48.530 [vert.x-eventloop-thread-0] INFO  o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - MQTT server running on 0.0.0.0:11883
14:37:48.533 [main] INFO  o.e.h.adapter.mqtt.impl.Application - Started Application in 2.542 seconds (JVM running for 3.01)
14:37:48.608 [vert.x-eventloop-thread-0] DEBUG o.e.h.c.impl.ConnectionFactoryImpl - connected to AMQP 1.0 container [amqp://127.0.0.1:5672], opening connection ...
14:37:48.611 [vert.x-eventloop-thread-0] DEBUG o.e.h.c.impl.ConnectionFactoryImpl - connected to AMQP 1.0 container [amqp://127.0.0.1:5672], opening connection ...
14:37:48.612 [vert.x-eventloop-thread-0] DEBUG o.e.h.c.impl.ConnectionFactoryImpl - connected to AMQP 1.0 container [amqp://127.0.0.1:5672], opening connection ...
14:37:48.612 [vert.x-eventloop-thread-0] DEBUG o.e.h.c.impl.ConnectionFactoryImpl - connected to AMQP 1.0 container [amqp://127.0.0.1:5672], opening connection ...
14:37:48.614 [vert.x-eventloop-thread-0] DEBUG o.e.h.c.impl.ConnectionFactoryImpl - connection to container [rabbit@bob-HP-ZBook-15-G4] at [amqp://127.0.0.1:5672] open
14:37:48.615 [vert.x-eventloop-thread-0] INFO  o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - connected to Tenant service
14:37:48.616 [vert.x-eventloop-thread-0] DEBUG o.e.h.c.impl.ConnectionFactoryImpl - connection to container [rabbit@bob-HP-ZBook-15-G4] at [amqp://127.0.0.1:5672] open
14:37:48.616 [vert.x-eventloop-thread-0] INFO  o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - connected to Messaging
14:37:48.616 [vert.x-eventloop-thread-0] DEBUG o.e.h.c.impl.ConnectionFactoryImpl - connection to container [rabbit@bob-HP-ZBook-15-G4] at [amqp://127.0.0.1:5672] open
14:37:48.616 [vert.x-eventloop-thread-0] INFO  o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - connected to Device Registration service
14:37:48.617 [vert.x-eventloop-thread-0] DEBUG o.e.h.c.impl.ConnectionFactoryImpl - connection to container [rabbit@bob-HP-ZBook-15-G4] at [amqp://127.0.0.1:5672] open
14:37:48.617 [vert.x-eventloop-thread-0] INFO  o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - connected to Credentials service
14:37:48.617 [vert.x-eventloop-thread-0] DEBUG o.e.h.c.impl.ConnectionFactoryImpl - connected to AMQP 1.0 container [amqp://127.0.0.1:5672], opening connection ...
14:37:48.618 [vert.x-eventloop-thread-0] DEBUG o.e.h.c.impl.ConnectionFactoryImpl - connection to container [rabbit@bob-HP-ZBook-15-G4] at [amqp://127.0.0.1:5672] open
14:37:48.618 [vert.x-eventloop-thread-0] INFO  o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - connected to Command and Control service

向 MQTT 适配器发送消息 (mosquitto_pub -p 11883 -t telemetry/DEFAULT_TENANT/4711 -m '{"temp": 5}') 时(示例取自https://www.eclipse.org/hono/user- guide/mqtt-adapter/),我正在登录 MQTT 适配器服务:

14:38:05.208 [vert.x-eventloop-thread-0] DEBUG o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - connection request from client [client-id: mosqpub|21426-bob-HP-ZB]
14:38:05.213 [vert.x-eventloop-thread-0] DEBUG o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - unauthenticated device [clientId: mosqpub|21426-bob-HP-ZB] connected
14:38:05.215 [vert.x-eventloop-thread-0] INFO  o.e.h.s.m.LoggingConnectionEventProducer -    Connected - ID: mosqpub|21426-bob-HP-ZB, Protocol Adapter: hono-mqtt, Device: null, Data: null
14:38:05.222 [vert.x-eventloop-thread-0] DEBUG o.e.hono.client.impl.HonoClientImpl - creating new message sender for telemetry/DEFAULT_TENANT
14:38:05.236 [vert.x-eventloop-thread-0] DEBUG o.e.hono.client.impl.HonoClientImpl - creating new client [target: registration/DEFAULT_TENANT]
14:38:05.236 [vert.x-eventloop-thread-0] DEBUG o.e.h.c.impl.RegistrationClientImpl - creating new registration client for [DEFAULT_TENANT]
14:38:05.246 [vert.x-eventloop-thread-0] INFO  o.e.h.c.i.AbstractRequestResponseClient - enabling caching of responses from registration/DEFAULT_TENANT
14:38:05.253 [vert.x-eventloop-thread-0] DEBUG o.e.hono.client.impl.HonoClientImpl - creating new client [target: tenant]
14:38:05.254 [vert.x-eventloop-thread-0] DEBUG o.e.h.client.impl.TenantClientImpl - creating new tenant client
14:38:05.254 [vert.x-eventloop-thread-0] INFO  o.e.h.c.i.AbstractRequestResponseClient - enabling caching of responses from tenant
14:38:05.258 [vert.x-eventloop-thread-0] INFO  o.e.hono.client.impl.HonoClientImpl - remote server [127.0.0.1:5672] closed connection with error condition: The connections default session closed unexpectedly: : io.vertx.core.impl.NoStackTraceThrowable: Error{condition=amqp:invalid-field, description='Attach rejected: {unknown_destination,"telemetry/DEFAULT_TENANT"}', info=null}
14:38:05.260 [vert.x-eventloop-thread-0] DEBUG o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - cannot process message [endpoint: telemetry] from device [tenantId: DEFAULT_TENANT, deviceId: 4711]
org.eclipse.hono.client.ServerErrorException: no connection to service
    at org.eclipse.hono.client.impl.HonoClientImpl.lambda$getOrCreateSender$16(HonoClientImpl.java:619)
    at org.eclipse.hono.client.impl.HonoClientImpl.failAllCreationRequests(HonoClientImpl.java:463)
    at org.eclipse.hono.client.impl.HonoClientImpl.clearState(HonoClientImpl.java:455)
    at org.eclipse.hono.client.impl.HonoClientImpl.handleConnectionLoss(HonoClientImpl.java:437)
    at org.eclipse.hono.client.impl.HonoClientImpl.onRemoteClose(HonoClientImpl.java:417)
    at org.eclipse.hono.client.impl.HonoClientImpl.lambda$connect$2(HonoClientImpl.java:372)
    at io.vertx.proton.impl.ProtonConnectionImpl.lambda$getDefaultSession$6(ProtonConnectionImpl.java:256)
    at io.vertx.proton.impl.ProtonSessionImpl.fireRemoteClose(ProtonSessionImpl.java:270)
    at io.vertx.proton.impl.ProtonTransport.handleSocketBuffer(ProtonTransport.java:125)
    at io.vertx.core.net.impl.NetSocketImpl$DataMessageHandler.handle(NetSocketImpl.java:384)
    at io.vertx.core.net.impl.NetSocketImpl.handleMessageReceived(NetSocketImpl.java:351)
    at io.vertx.core.net.impl.NetClientImpl$1.handleMessage(NetClientImpl.java:242)
    at io.vertx.core.net.impl.NetClientImpl$1.handleMessage(NetClientImpl.java:239)
    at io.vertx.core.net.impl.VertxHandler.lambda$channelRead$1(VertxHandler.java:146)
    at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:337)
    at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:195)
    at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:144)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:935)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:141)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:844)
14:38:05.261 [vert.x-eventloop-thread-0] DEBUG o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - discarding message [topic: telemetry/DEFAULT_TENANT/4711] from device: no connection to service

它试图连接到哪个服务?一个小问题:在 docker_swarm.sh 中我还注意到了消息服务,它是用来做什么的?在https://www.eclipse.org/hono/getting-started/#starting-hono上没有提到。

提前致谢!

4

1 回答 1

2

Hono 不(官方)支持 RabbitMQ 作为 AMQP 1.0 消息传递网络。但是,基于 Rabbit 对 AMQP 1.0 的支持,您可能仍然可以使用它。也就是说,看起来 MQTT 适配器无法打开到 Rabbit 的发件人链接,这似乎拒绝了适配器在目标地址上打开发件人的请求telemetry/DEFAULT_TENANT。这可能是由于 Rabbit作为消息代理的起源,它需要在运行时使用之前定义队列和/或主题。

我不是 RabbitMQ 专家,但我认为你应该弄清楚

  • 如何配置 RabbitMQ 以便在对等点打开相应链接时在运行时动态创建队列/主题,或者
  • 在 RabbitMQ 中预先定义相应的队列,例如通过将它们添加到 Rabbit 的配置文件中。

如果不是必须使用 RabbitMQ,我实际上建议将 Qpid Dispatch Router 与 Apache MQ Artemis 一起使用。您将获得 Hono 开发团队更好的支持,因为这是用于开发的 AMQP 消息网络的官方实现。

关于您的旁注:在 Hono 0.7 之前,所有协议适配器都必须连接到消息传递服务,该服务在消息流中提供了一个中心点,Hono 可以在该中心点验证遥测消息或事件的来源,然后再将其向下游转发到 AMQP 消息传递网络(以及因此消耗的应用程序)。

为此,协议适配器需要在每条消息中包含一个 JSON Web 令牌,该令牌从连接设备的设备注册服务中获得,并声明设备的注册状态。然后,Hono Messaging 将验证 JWT 的签名,从而确保消息来自实际启用协议适配器的租户的现有(注册)设备。这个想法是设备注册表不会为适配器未授权的设备发出 JWT。这对于自定义的场景特别有用(第三方提供)协议适配器应与 Hono 安装集成(例如,针对特定租户),但应阻止该协议适配器代表或不属于适配器已授权的租户的任意设备向下游发送消息为了。

在最近的版本中,我们放弃了这个组件,转而在 AMQP 消息传递网络中授权协议适配器。

日志记录

所有 Hono 服务将信息记录到标准输出。可以通过spring.profiles.activeJava 系统属性设置日志级别。如果未设置,服务将在 INFO 级别记录,仅提供有关组件正在经历的生命周期事件的非常有限的信息。为了打开更详尽的调试日志记录,请-Dspring.profiles.active=dev在启动 JVM 时像这样设置系统属性。

于 2018-10-15T16:10:59.970 回答