eclipse-paho / eclipse-paho/paho.mqtt.java

Getting Exception Caused by: MqttException (0) - java.io.IOException: WebSocket Response header: Incorrect upgrade.

Open
#992 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.3k
Forks
919
PR merge metrics
No merged PRs in 30d

Description

Please fill out the form below before submitting, thank you!

- [x] Bug exists Release Version 1.2.5 ( Master Branch)

While connecting to mqtt broker getting this Exception.

Version : 1.2.5

Gradle dependency : implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'

code being used to connect

```
private MqttAsyncClient instantiateNewMqttConnection() {
logger.info("Intantiate new MQTT connection....");
logger.info("Connecting to MQTT Broker: " + this.params.url);
MqttAsyncClient client = null;
try {
client = new MqttAsyncClient(this.params.url, this.params.clientId, new MemoryPersistence());
client.setCallback(new MqttConnectionCallBack(this.params.clientId));
MqttConnectOptions options = new MqttConnectOptions();
// options.setSkipPortDuringHandshake(true);
options.setCleanSession(true);
client.connect(options).waitForCompletion();
} catch (MqttException e) {
logger.info("MQTT Connection Failed");
logger.info(e.getMessage());
logger.info(e.getCause().toString());
logger.info(e.getStackTrace().toString());
Assert.fail("Failed due to MQTT connection could not be made");
}
return client;
}
```

Same result with below code

```
private MqttClient instantiateNewMqttConnection() {
logger.info("Intantiate new MQTT connection....");
logger.info("Connecting to MQTT Broker: " + this.params.url);
MqttClient client = null;
try {
client = new MqttClient(this.params.url, this.params.clientId, new MemoryPersistence());
client.setCallback(new MqttConnectionCallBack(this.params.clientId));
MqttConnectOptions options = new MqttConnectOptions();
// options.setSkipPortDuringHandshake(true);
options.setCleanSession(true);
client.connect(options);
} catch (MqttException e) {
logger.info("MQTT Connection Failed");
logger.info(e.getMessage());
logger.info(e.getCause().toString());
logger.info(e.getStackTrace().toString());
Assert.fail("Failed due to MQTT connection could not be made");
}
return client;
}
```

Note: URL starts with wss:// and it is being used to connect with AWSIOTMQTT broker.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.