Skip to content

Commit 3641c5f

Browse files
Ian CraggsGerrit Code Review @ Eclipse.org
authored andcommitted
Merge "Bug: 484264 - Null pointer in Paho Java client WebSocket classes" into develop
2 parents 1fcf24e + d796504 commit 3641c5f

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/MqttAsyncClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ else if ((factory instanceof SSLSocketFactory) == false) {
411411
case MqttConnectOptions.URI_TYPE_WS:
412412
shortAddress = address.substring(5);
413413
host = getHostName(shortAddress);
414-
port = getPort(shortAddress, 1883);
414+
port = getPort(shortAddress, 80);
415415
if (factory == null) {
416416
factory = SocketFactory.getDefault();
417417
}
@@ -424,7 +424,7 @@ else if (factory instanceof SSLSocketFactory) {
424424
case MqttConnectOptions.URI_TYPE_WSS:
425425
shortAddress = address.substring(6);
426426
host = getHostName(shortAddress);
427-
port = getPort(shortAddress, 8883);
427+
port = getPort(shortAddress, 443);
428428
SSLSocketFactoryFactory wSSFactoryFactory = null;
429429
if (factory == null) {
430430
wSSFactoryFactory = new SSLSocketFactoryFactory();

org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/internal/websocket/WebSocketHandshake.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ private void receiveHandshakeResponse(String key) throws IOException {
9494
BufferedReader in = new BufferedReader(new InputStreamReader(input));
9595
ArrayList responseLines = new ArrayList();
9696
String line = in.readLine();
97+
if(line == null){
98+
throw new IOException("WebSocket Response header: Invalid response from Server, It may not support WebSockets.");
99+
}
97100
while(!line.equals(EMPTY) ) {
98101
responseLines.add(line);
99102
line = in.readLine();

0 commit comments

Comments
 (0)