独来独往mk 2017-11-09 05:12 采纳率: 0%
浏览 4229

Mqtt 整合 spring mvc, 启动时候的时候可以链接,但是接收消息就失去链接

异常信息:
1. 启动的时候,控制台会打印出close, 这是outbond通道的类打印出来的
2. 我模拟product发送一条数据,tomcat控制台输出异常信息
ERROR inbound.MqttPahoMessageDrivenChannelAdapter - Lost connection:宸叉柇寮?繛鎺? retrying...
ERROR inbound.MqttPahoMessageDrivenChannelAdapter - Lost connection:宸叉柇寮?繛鎺? retrying...
接收到信息ooo:close

  • 写回答

4条回答 默认 最新

  • 独来独往mk 2017-11-09 05:14
    关注

    我的配置如下:
    mqtt.xml

    <bean id="clientFactory"
        class="org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory">
        <property name="userName" value="admin" />
        <property name="password" value="password" />
    </bean>
    
    <!-- 消息适配器  -->
    <int-mqtt:message-driven-channel-adapter
        id="mqttInbound" 
        client-id="CID_2016524123456" 
        url="tcp://localhost:61613"
        topics="iot"
        qos="1"
        client-factory="clientFactory" 
        auto-startup="true"
        send-timeout="12"
        channel="output" />
    
    <int:service-activator input-channel="output"  method="handleMessage" ref="mqttLogger" />
    <bean id="mqttLogger" class="com.iot.device.mqtt.MqttReciever" />   
    
    <int:service-activator input-channel="errorChannel" ref="errorMessageLogger" method="logError" />
    <bean id="errorMessageLogger" class="com.iot.device.mqtt.ErrorMessageLogger" />
    
    评论

报告相同问题?