2017-04-04 247 views
0

我有一個AWS IoT問題。我在月份使用相同的代碼。但突然它停止工作。我使用AWS IoT通過Websocket使用Mqtt。使用AWS IoT通過Websocket與MQTT錯誤連接標頭

這是我使用的簡單代碼。

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 

在這個階段,我不知道什麼是錯的。我在月份使用這段代碼。沒有任何改變,現在它停止工作。

如果有人能幫我解決這個問題,那就太棒了。謝謝。

回答