【问题标题】:Incorrect connection header with MQTT over Websocket with AWS IoT使用 AWS IoT 通过 Websocket 使用 MQTT 的连接标头不正确
【发布时间】:2017-08-30 04:01:52
【问题描述】:

我对 AWS IoT 有疑问。我一个月都在使用相同的代码。但突然它停止工作了。我在 AWS IoT 中使用 Mqtt over Websocket。

这是我使用的简单代码。

import com.amazonaws.services.iot.client.AWSIotException;
import com.amazonaws.services.iot.client.AWSIotMqttClient;

public class ThingMain {

    public static void main(String[] args) {

        String clientEndpoint = "endpoint.iot.us-west-2.amazonaws.com";
        String clientId = "testing";

        AWSIotMqttClient client = new AWSIotMqttClient(clientEndpoint, clientId, "accessKey", "secretKey");

        try {
            client.connect();
        } catch (AWSIotException e) {
            e.printStackTrace();
        }
   }
}

我得到了这个日志:

AVERTISSEMENT: Connect request failure
MqttException (0) - java.io.IOException: WebSocket Response header: Incorrect connection header
    at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
    at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:690)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: WebSocket Response header: Incorrect connection header
    at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:144)
    at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
    at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
    at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:676)
    ... 1 more

avr. 04, 2017 11:00:55 PM 
com.amazonaws.services.iot.client.core.AwsIotConnection onConnectionFailure
INFOS: Connection temporarily lost
avr. 04, 2017 11:00:55 PM 
com.amazonaws.services.iot.client.core.AbstractAwsIotClient onConnectionFailure
INFOS: Client connection lost: leet
avr. 04, 2017 11:00:58 PM 
com.amazonaws.services.iot.client.core.AwsIotConnection$1 run
INFOS: Connection is being retried

在这个阶段,我不知道出了什么问题。我用这个代码一个月了。什么都没有改变,现在它停止工作了。

如果有人能帮我解决这个问题,那就太棒了。谢谢。

【问题讨论】:

    标签: amazon-web-services mqtt iot aws-iot


    【解决方案1】:

    https://github.com/aws/aws-iot-device-sdk-java/issues/23

    可能是由于 org.eclipse.paho 升级 v1.1.1

    【讨论】:

    • 感谢这解决了我的问题。我将此行添加到我的依赖项"compile (group: 'org.eclipse.paho', name: 'org.eclipse.paho.client.mqttv3', version: '1.1.0'){force = true}"
    【解决方案2】:

    我也有同样的问题,实际上,如果您在多个地区使用相同的访问密钥和密钥,您将面临这个问题。我为每个地区创建了不同的用户。它解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2021-12-15
      • 1970-01-01
      • 1970-01-01
      • 2020-05-19
      • 1970-01-01
      • 2021-01-09
      • 2018-06-14
      • 1970-01-01
      • 2022-12-07
      相关资源
      最近更新 更多