2
votes

I can connect to my MQTT broker with Python bindings, but I'm trying to reproduce the same thing with Java and it appears that there is successful SSH handshake but after sending MQTT connect message there is no response. What might be the reason?

My code:

package com.daniel.qa.common.services.mqtt;

import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;

import javax.net.ssl.*;
import java.net.Socket;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.logging.*;

public class MqttTest {


    public static void setDebugLevel(Level newLvl) {
        Logger rootLogger = LogManager.getLogManager().getLogger("");
        rootLogger.addHandler(new ConsoleHandler());
        Handler[] handlers = rootLogger.getHandlers();
        rootLogger.setLevel(newLvl);
        for (Handler h : handlers) {
            h.setLevel(newLvl);
        }
    }


    public static void main(String[] args) {

        setDebugLevel(Level.FINEST);

        String topic = "MQTT Examples";
        String content = "Message from MqttPublishSample";
        int qos = 1;
        String broker = "ssl://super-car.na.mqtt.daniel.com:8883";
        MemoryPersistence persistence = new MemoryPersistence();

        try {
            // Create a trust manager that does not validate certificate chains
            TrustManager[] trustAllCerts = new TrustManager[]{
                    new X509ExtendedTrustManager() {
                        @Override
                        public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
                        }

                        @Override
                        public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
                        }

                        @Override
                        public X509Certificate[] getAcceptedIssuers() {
                            return null;
                        }

                        @Override
                        public void checkClientTrusted(X509Certificate[] x509Certificates, String s, Socket socket) throws CertificateException {
                        }

                        @Override
                        public void checkServerTrusted(X509Certificate[] x509Certificates, String s, Socket socket) throws CertificateException {
                        }

                        @Override
                        public void checkClientTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) throws CertificateException {
                        }

                        @Override
                        public void checkServerTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) throws CertificateException {
                        }
                    }
            };

            // Install the all-trusting trust manager
            System.setProperty("jdk.tls.client.protocols", "TLSv1");
            SSLContext sc = SSLContext.getInstance("TLS");
            sc.init(null, trustAllCerts, new java.security.SecureRandom());

            MqttClient sampleClient = new MqttClient(broker, "pahoClientId", persistence);
            MqttConnectOptions connOpts = new MqttConnectOptions();
            connOpts.setCleanSession(true);
            connOpts.setSocketFactory(sc.getSocketFactory());
            System.out.println("Connecting to broker: " + broker);
            sampleClient.connect(connOpts);
            System.out.println("Connected");
            System.out.println("Publishing message: " + content);
            MqttMessage message = new MqttMessage(content.getBytes());
            message.setQos(qos);
            sampleClient.publish(topic, message);
            System.out.println("Message published");
            sampleClient.disconnect();
            System.out.println("Disconnected");
            System.exit(0);
        } catch (MqttException me) {
            System.out.println("reason " + me.getReasonCode());
            System.out.println("msg " + me.getMessage());
            System.out.println("loc " + me.getLocalizedMessage());
            System.out.println("cause " + me.getCause());
            System.out.println("excep " + me);
            me.printStackTrace();
        } catch (NoSuchAlgorithmException | KeyManagementException e) {
            e.printStackTrace();
        }
    }
}

Logs at FINEST level:

Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.MqttAsyncClient MqttAsyncClient FINE: pahoClientId: ClientID=pahoClientId ServerURI=ssl://super-car.na.mqtt.akamai.com:8883 PersistenceType=org.eclipse.paho.client.mqttv3.persist.MemoryPersistence@4d49af10 Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.MqttAsyncClient MqttAsyncClient FINE: pahoClientId: ClientID=pahoClientId ServerURI=ssl://super-car.na.mqtt.akamai.com:8883 PersistenceType=org.eclipse.paho.client.mqttv3.persist.MemoryPersistence@4d49af10 Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore FINE: pahoClientId: <> Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore FINE: pahoClientId: <> Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.ClientState FINER: pahoClientId: Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.ClientState FINER: pahoClientId: Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.ClientState restoreState FINE: pahoClientId: > Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.ClientState restoreState FINE: pahoClientId: > Connecting to broker: ssl://super-car.na.mqtt.akamai.com:8883 Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.MqttAsyncClient connect FINE: pahoClientId: cleanSession=true connectionTimeout=30 TimekeepAlive=60 userName=null password=[null] will=[null] userContext=null callback=null Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.MqttAsyncClient connect FINE: pahoClientId: cleanSession=true connectionTimeout=30 TimekeepAlive=60 userName=null password=[null] will=[null] userContext=null callback=null Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.MqttAsyncClient createNetworkModules FINE: pahoClientId: URI=ssl://super-car.na.mqtt.akamai.com:8883 Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.MqttAsyncClient createNetworkModules FINE: pahoClientId: URI=ssl://super-car.na.mqtt.akamai.com:8883 Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.MqttAsyncClient createNetworkModule FINE: pahoClientId: URI=ssl://super-car.na.mqtt.akamai.com:8883 Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.MqttAsyncClient createNetworkModule FINE: pahoClientId: URI=ssl://super-car.na.mqtt.akamai.com:8883 Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.MqttAsyncClient createNetworkModules FINE: pahoClientId: < Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.MqttAsyncClient createNetworkModules FINE: pahoClientId: < Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.ClientComms connect FINE: pahoClientId: state=CONNECTING Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.ClientComms connect FINE: pahoClientId: state=CONNECTING Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore open FINE: pahoClientId: > Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore open FINE: pahoClientId: > Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.ClientComms connectBG:run FINE: pahoClientId: > Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.Token waitForCompletion FINE: pahoClientId: key=null wait max=-1 token=key=null ,topics= ,usercontext=org.eclipse.paho.client.mqttv3.MqttAsyncClient@5db45159 ,isComplete=false ,isNotified=false ,exception=null ,actioncallback=org.eclipse.paho.client.mqttv3.internal.ConnectActionListener@6107227e Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.ClientComms connectBG:run FINE: pahoClientId: > Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.Token waitForCompletion FINE: pahoClientId: key=null wait max=-1 token=key=null ,topics= ,usercontext=org.eclipse.paho.client.mqttv3.MqttAsyncClient@5db45159 ,isComplete=false ,isNotified=false ,exception=null ,actioncallback=org.eclipse.paho.client.mqttv3.internal.ConnectActionListener@6107227e Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore getOutstandingDelTokens FINE: pahoClientId: > Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.Token waitForResponse FINE: pahoClientId: >key=null timeout=-1 sent=false completed=false hasException=false response=null token=key=null ,topics= ,usercontext=org.eclipse.paho.client.mqttv3.MqttAsyncClient@5db45159 ,isComplete=false ,isNotified=false ,exception=null ,actioncallback=org.eclipse.paho.client.mqttv3.internal.ConnectActionListener@6107227e Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore getOutstandingDelTokens FINE: pahoClientId: > Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.Token waitForResponse FINE: pahoClientId: >key=null timeout=-1 sent=false completed=false hasException=false response=null token=key=null ,topics= ,usercontext=org.eclipse.paho.client.mqttv3.MqttAsyncClient@5db45159 ,isComplete=false ,isNotified=false ,exception=null ,actioncallback=org.eclipse.paho.client.mqttv3.internal.ConnectActionListener@6107227e Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.Token waitForResponse FINE: pahoClientId: key=null wait max=-1 Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore saveToken FINE: pahoClientId: key=Con message=CONNECT clientId pahoClientId keepAliveInterval 60 Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.Token waitForResponse FINE: pahoClientId: key=null wait max=-1 Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore saveToken FINE: pahoClientId: key=Con message=CONNECT clientId pahoClientId keepAliveInterval 60 Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore saveToken FINE: pahoClientId: key=Con token=org.eclipse.paho.client.mqttv3.MqttToken@767dab68 Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore saveToken FINE: pahoClientId: key=Con token=org.eclipse.paho.client.mqttv3.MqttToken@767dab68 Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule start FINE: pahoClientId: connect to host super-car.na.mqtt.akamai.com port 8,883 timeout 0 Jan 11, 2018 5:16:26 PM org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule start FINE: pahoClientId: connect to host super-car.na.mqtt.akamai.com port 8,883 timeout 0 Jan 11, 2018 5:16:28 PM org.eclipse.paho.client.mqttv3.internal.CommsReceiver start FINE: pahoClientId: starting Jan 11, 2018 5:16:28 PM org.eclipse.paho.client.mqttv3.internal.CommsReceiver start FINE: pahoClientId: starting Jan 11, 2018 5:16:28 PM org.eclipse.paho.client.mqttv3.internal.CommsReceiver run FINE: pahoClientId: network read message Jan 11, 2018 5:16:28 PM org.eclipse.paho.client.mqttv3.internal.CommsReceiver run FINE: pahoClientId: network read message Jan 11, 2018 5:16:28 PM org.eclipse.paho.client.mqttv3.internal.ClientState get FINE: pahoClientId: wait for 60,000 ms for new work or for space in the inflight window Jan 11, 2018 5:16:28 PM org.eclipse.paho.client.mqttv3.internal.ClientState get FINE: pahoClientId: wait for 60,000 ms for new work or for space in the inflight window Jan 11, 2018 5:16:30 PM org.eclipse.paho.client.mqttv3.internal.ClientComms internalSend FINE: pahoClientId: internalSend key=Con message=CONNECT clientId pahoClientId keepAliveInterval 60 token=org.eclipse.paho.client.mqttv3.MqttToken@767dab68 Jan 11, 2018 5:16:30 PM org.eclipse.paho.client.mqttv3.internal.ClientComms internalSend FINE: pahoClientId: internalSend key=Con message=CONNECT clientId pahoClientId keepAliveInterval 60 token=org.eclipse.paho.client.mqttv3.MqttToken@767dab68 Jan 11, 2018 5:16:28 PM org.eclipse.paho.client.mqttv3.internal.CommsCallback run FINE: pahoClientId: wait for workAvailable Jan 11, 2018 5:16:28 PM org.eclipse.paho.client.mqttv3.internal.CommsCallback run FINE: pahoClientId: wait for workAvailable Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientState send FINE: pahoClientId: pending send key=0 message CONNECT clientId pahoClientId keepAliveInterval 60 Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientState send FINE: pahoClientId: pending send key=0 message CONNECT clientId pahoClientId keepAliveInterval 60 Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore saveToken FINE: pahoClientId: key=Con message=CONNECT clientId pahoClientId keepAliveInterval 60 Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore saveToken FINE: pahoClientId: key=Con message=CONNECT clientId pahoClientId keepAliveInterval 60 Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore saveToken FINE: pahoClientId: key=Con token=org.eclipse.paho.client.mqttv3.MqttToken@767dab68 Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore saveToken FINE: pahoClientId: key=Con token=org.eclipse.paho.client.mqttv3.MqttToken@767dab68 Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsSender run FINE: pahoClientId: network send key=Con msg=CONNECT clientId pahoClientId keepAliveInterval 60 Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsSender run FINE: pahoClientId: network send key=Con msg=CONNECT clientId pahoClientId keepAliveInterval 60 Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.wire.MqttOutputStream write FINE: null: 500 Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.wire.MqttOutputStream write FINE: null: 500 Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientState notifySent FINE: pahoClientId: key=Con Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientState notifySent FINE: pahoClientId: key=Con Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.Token notifySent FINE: pahoClientId: > key=Con Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.Token notifySent FINE: pahoClientId: > key=Con Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientState get FINE: pahoClientId: wait for 60,000 ms for new work or for space in the inflight window Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientState get FINE: pahoClientId: wait for 60,000 ms for new work or for space in the inflight window Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsReceiver run FINE: pahoClientId: Stopping due to IOException Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsReceiver run FINE: pahoClientId: Stopping due to IOException Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientComms shutdownConnection FINE: pahoClientId: state=DISCONNECTING Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientComms shutdownConnection FINE: pahoClientId: state=DISCONNECTING Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsCallback stop FINE: pahoClientId: stopping Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsCallback stop FINE: pahoClientId: stopping Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsCallback stop FINE: pahoClientId: notify workAvailable and wait for run Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsCallback stop FINE: pahoClientId: notify workAvailable and wait for run Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsCallback run FINE: pahoClientId: notify spaceAvailable Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsCallback run FINE: pahoClientId: notify spaceAvailable Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsCallback stop FINE: pahoClientId: stopped Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsCallback stop FINE: pahoClientId: stopped Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsReceiver stop FINE: pahoClientId: stopping Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsReceiver stop FINE: pahoClientId: stopping Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsReceiver stop FINE: pahoClientId: stopped Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsReceiver stop FINE: pahoClientId: stopped Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore quiesce FINE: pahoClientId: resp=Client is currently disconnecting (32102) Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore quiesce FINE: pahoClientId: resp=Client is currently disconnecting (32102) Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientComms handleOldTokens FINE: pahoClientId: > Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientComms handleOldTokens FINE: pahoClientId: > Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientState resolveOldTokens FINE: pahoClientId: reason Connection lost (32109) - java.io.EOFException Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientState resolveOldTokens FINE: pahoClientId: reason Connection lost (32109) - java.io.EOFException Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore getOutstandingTokens FINE: pahoClientId: > Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore getOutstandingTokens FINE: pahoClientId: > Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore removeToken FINE: pahoClientId: key=Con Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore removeToken FINE: pahoClientId: key=Con Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientState disconnected FINE: pahoClientId: disconnected Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientState disconnected FINE: pahoClientId: disconnected Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientState clearState FINE: pahoClientId: > Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientState clearState FINE: pahoClientId: > Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore clear FINE: pahoClientId: > 0 tokens Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsTokenStore clear FINE: pahoClientId: > 0 tokens Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsSender stop FINE: pahoClientId: stopping sender Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsSender stop FINE: pahoClientId: stopping sender Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientState notifyQueueLock FINE: pahoClientId: notifying queueLock holders Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientState notifyQueueLock FINE: pahoClientId: notifying queueLock holders Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientState get FINE: pahoClientId: no outstanding flows and not connected Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientState get FINE: pahoClientId: no outstanding flows and not connected Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsSender run FINE: pahoClientId: get message returned null, stopping} Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsSender run FINE: pahoClientId: get message returned null, stopping} Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsSender run FINE: pahoClientId: < Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsSender run FINE: pahoClientId: < Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsSender stop FINE: pahoClientId: stopped Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsSender stop FINE: pahoClientId: stopped Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientComms shutdownConnection FINE: pahoClientId: state=DISCONNECTED Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.ClientComms shutdownConnection FINE: pahoClientId: state=DISCONNECTED Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsCallback handleActionComplete FINE: pahoClientId: callback and notify for key=Con Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsCallback handleActionComplete FINE: pahoClientId: callback and notify for key=Con Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.Token notifyComplete FINE: pahoClientId: >key=Con response=null excep=Connection lost (32109) - java.io.EOFException Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.Token notifyComplete FINE: pahoClientId: >key=Con response=null excep=Connection lost (32109) - java.io.EOFException Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsCallback fireActionEvent FINE: pahoClientId: call onSuccess key=Con Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsCallback fireActionEvent FINE: pahoClientId: call onSuccess key=Con Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.Token markComplete FINE: pahoClientId: >key=null response=null excep=Connection lost (32109) - java.io.EOFException Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.Token markComplete FINE: pahoClientId: >key=null response=null excep=Connection lost (32109) - java.io.EOFException Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.Token notifyComplete FINE: pahoClientId: >key=null response=null excep=Connection lost (32109) - java.io.EOFException Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.Token notifyComplete FINE: pahoClientId: >key=null response=null excep=Connection lost (32109) - java.io.EOFException Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsReceiver run FINE: pahoClientId: < Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.CommsReceiver run FINE: pahoClientId: < Disconnected from the target VM, address: '127.0.0.1:53751', transport: 'socket' reason 32109 msg Connection lost loc Connection lost cause java.io.EOFException excep Connection lost (32109) - java.io.EOFException Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.Token waitForResponse FINE: pahoClientId: failed with exception Connection lost (32109) - java.io.EOFException at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:138) at java.lang.Thread.run(Thread.java:748) Caused by: java.io.EOFException at java.io.DataInputStream.readByte(DataInputStream.java:267) at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:56) at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:100) ... 1 more

Jan 11, 2018 5:16:31 PM org.eclipse.paho.client.mqttv3.internal.Token waitForResponse FINE: pahoClientId: failed with exception Connection lost (32109) - java.io.EOFException at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:138) at java.lang.Thread.run(Thread.java:748) Caused by: java.io.EOFException at java.io.DataInputStream.readByte(DataInputStream.java:267) at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:56) at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:100) ... 1 more

Connection lost (32109) - java.io.EOFException at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:138) at java.lang.Thread.run(Thread.java:748) Caused by: java.io.EOFException at java.io.DataInputStream.readByte(DataInputStream.java:267) at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:56) at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:100) ... 1 more

Process finished with exit code 0

1

1 Answers

0
votes

The problem was MQTT version - in first Java version I had older library - mqtt-client 0.4.0 - which had MQTT 3.1, and broker did not support it so it was terminating SSL connection when noticed it. When I switched to a more recent one (org.eclipse.paho.client.mqttv3 1.0.2, with MQTT 3.1.1), the connection was successful.