I am sure that all credential are correct and accurate.
I have tried using mosquitto_pub (v2.0.18) and MQTTBox to connect and published to the Azure Iot Hub port 8883 So I assumed I have the correct credential and cert.
I have search through Paho Github and also stackoverflow and it seems to be fix in previous version but yet surface again in later version.
When I use my Java client to connect throws the following errors:
Connection lost (32109) - java.io.EOFException
at
org.eclipse.paho.mqttv5.client.internal.CommsReceiver.run(CommsReceiver.java:196)
at java.lang.Thread.run(Thread.java:750)
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)
at
org.eclipse.paho.mqttv5.client.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:96)
at
org.eclipse.paho.mqttv5.client.internal.CommsReceiver.run(CommsReceiver.java:139)
... 1 more
I have also run debug for the paho
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.MqttAsyncClient MqttAsyncClient
FINE: dio: ClientID=dio ServerURI=ssl://mura-iot.azure-devices.net:8883 PersistenceType=org.eclipse.paho.mqttv5.client.persist.MemoryPersistence@6ad21b4b
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.internal.CommsTokenStore
FINE: dio:
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.internal.ClientState
FINER: dio:
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.internal.ClientState restoreState
FINE: dio: >
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.MqttAsyncClient connect
FINE: dio: cleanStart=true connectionTimeout=300 TimekeepAlive=60 userName=mura-iot.azure-devices.net/dio/?api-version=2021-04-12 password=[notnull] will=[null] userContext=null callback=null
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.MqttAsyncClient createNetworkModules
FINE: dio: URI=ssl://mura-iot.azure-devices.net:8883
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.MqttAsyncClient createNetworkModule
FINE: dio: URI=ssl://mura-iot.azure-devices.net:8883
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.MqttAsyncClient createNetworkModules
FINE: dio: <
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.internal.ClientComms connect
FINE: dio: state=CONNECTING
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.internal.CommsTokenStore open
FINE: dio: >
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.internal.Token waitForCompletion
FINE: dio: key=null wait max=5,000 token=key=null ,topics= ,usercontext=org.eclipse.paho.mqttv5.client.MqttAsyncClient@2d75c9bc ,isComplete=false ,isNotified=false ,exception=null ,actioncallback=org.eclipse.paho.mqttv5.client.internal.ConnectActionListener@f9664ad
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.internal.ClientComms connectBG:run
FINE: dio: >
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.internal.CommsTokenStore getOutstandingDelTokens
FINE: dio: >
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.internal.Token waitForResponse
FINE: dio: >key=null timeout=5,000 sent=false completed=false hasException=false response=null token=key=null ,topics= ,usercontext=org.eclipse.paho.mqttv5.client.MqttAsyncClient@2d75c9bc ,isComplete=false ,isNotified=false ,exception=null ,actioncallback=org.eclipse.paho.mqttv5.client.internal.ConnectActionListener@f9664ad
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.internal.CommsTokenStore saveToken
FINE: dio: key=Con message=MqttConnect [properties=MqttProperties [validProperties=[17, 24, 33, 39, 34, 25, 23, 38, 21, 22]], willProperties=MqttProperties [validProperties=[24, 1, 2, 8, 9, 38, 3]], info=0, clientId=dio, reservedByte=false, cleanStart=true, willMessage=null, userName=mura-iot.azure-devices.net/dio/?api-version=2021-04-12, password=[83, 104, 97, 114, 101, 100, 65, 99, 99, 101, 115, 115, 83, 105, 103, 110, 97, 116, 117, 114, 101, 32, 115, 114, 61, 97, 108, 118, 105, 110, 45, 105, 111, 116, 46, 97, 122, 117, 114, 101, 45, 100, 101, 118, 105, 99, 101, 115, 46, 110, 101, 116, 37, 50, 70, 100, 101, 118, 105, 99, 101, 115, 37, 50, 70, 100, 105, 111, 100, 101, 38, 115, 105, 103, 61, 79, 37, 50, 66, 56, 67, 106, 117, 65, 88, 66, 101, 97, 106, 103, 101, 101, 56, 121, 51, 90, 97, 112, 103, 97, 65, 122, 66, 107, 109, 88, 57, 37, 50, 70, 87, 113, 88, 122, 76, 85, 66, 122, 114, 71, 104, 89, 37, 51, 68, 38, 115, 101, 61, 49, 55, 51, 54, 49, 52, 57, 50, 56, 57], keepAliveInterval=60, willDestination=null, mqttVersion=5]
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.internal.Token waitForResponse
FINE: dio: key=null wait max=5,000
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.internal.CommsTokenStore saveToken
FINE: dio: key=Con token=org.eclipse.paho.mqttv5.client.MqttToken@75bfff01
Oct 09, 2024 11:59:01 AM org.eclipse.paho.mqttv5.client.internal.TCPNetworkModule start
FINE: dio: connect to host mura-iot.azure-devices.net port 8,883 timeout 300,000
Oct 09, 2024 11:59:02 AM org.eclipse.paho.mqttv5.client.internal.CommsReceiver start
FINE: dio: starting
Oct 09, 2024 11:59:02 AM org.eclipse.paho.mqttv5.client.internal.CommsReceiver run
FINE: dio: network read message
Oct 09, 2024 11:59:02 AM org.eclipse.paho.mqttv5.client.internal.ClientState get
FINE: dio: wait for new work or for space in the inflight window
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsCallback run
FINE: dio: wait for workAvailable
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientComms internalSend
FINE: dio: 200
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientState send
FINE: dio: pending send key=0 message MqttConnect [properties=MqttProperties [validProperties=[17, 24, 33, 39, 34, 25, 23, 38, 21, 22]], willProperties=MqttProperties [validProperties=[24, 1, 2, 8, 9, 38, 3]], info=0, clientId=dio, reservedByte=false, cleanStart=true, willMessage=null, userName=mura-iot.azure-devices.net/dio/?api-version=2021-04-12, password=[83, 104, 97, 114, 101, 100, 65, 99, 99, 101, 115, 115, 83, 105, 103, 110, 97, 116, 117, 114, 101, 32, 115, 114, 61, 97, 108, 118, 105, 110, 45, 105, 111, 116, 46, 97, 122, 117, 114, 101, 45, 100, 101, 118, 105, 99, 101, 115, 46, 110, 101, 116, 37, 50, 70, 100, 101, 118, 105, 99, 101, 115, 37, 50, 70, 100, 105, 111, 100, 101, 38, 115, 105, 103, 61, 79, 37, 50, 66, 56, 67, 106, 117, 65, 88, 66, 101, 97, 106, 103, 101, 101, 56, 121, 51, 90, 97, 112, 103, 97, 65, 122, 66, 107, 109, 88, 57, 37, 50, 70, 87, 113, 88, 122, 76, 85, 66, 122, 114, 71, 104, 89, 37, 51, 68, 38, 115, 101, 61, 49, 55, 51, 54, 49, 52, 57, 50, 56, 57], keepAliveInterval=60, willDestination=null, mqttVersion=5]
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsTokenStore saveToken
FINE: dio: key=Con message=MqttConnect [properties=MqttProperties [validProperties=[17, 24, 33, 39, 34, 25, 23, 38, 21, 22]], willProperties=MqttProperties [validProperties=[24, 1, 2, 8, 9, 38, 3]], info=0, clientId=dio, reservedByte=false, cleanStart=true, willMessage=null, userName=mura-iot.azure-devices.net/dio/?api-version=2021-04-12, password=[83, 104, 97, 114, 101, 100, 65, 99, 99, 101, 115, 115, 83, 105, 103, 110, 97, 116, 117, 114, 101, 32, 115, 114, 61, 97, 108, 118, 105, 110, 45, 105, 111, 116, 46, 97, 122, 117, 114, 101, 45, 100, 101, 118, 105, 99, 101, 115, 46, 110, 101, 116, 37, 50, 70, 100, 101, 118, 105, 99, 101, 115, 37, 50, 70, 100, 105, 111, 100, 101, 38, 115, 105, 103, 61, 79, 37, 50, 66, 56, 67, 106, 117, 65, 88, 66, 101, 97, 106, 103, 101, 101, 56, 121, 51, 90, 97, 112, 103, 97, 65, 122, 66, 107, 109, 88, 57, 37, 50, 70, 87, 113, 88, 122, 76, 85, 66, 122, 114, 71, 104, 89, 37, 51, 68, 38, 115, 101, 61, 49, 55, 51, 54, 49, 52, 57, 50, 56, 57], keepAliveInterval=60, willDestination=null, mqttVersion=5]
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsTokenStore saveToken
FINE: dio: key=Con token=org.eclipse.paho.mqttv5.client.MqttToken@75bfff01
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientState get
FINE: dio: new work or ping arrived
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsSender run
FINE: dio: network send key=Con msg=MqttConnect [properties=MqttProperties [validProperties=[17, 24, 33, 39, 34, 25, 23, 38, 21, 22]], willProperties=MqttProperties [validProperties=[24, 1, 2, 8, 9, 38, 3]], info=0, clientId=dio, reservedByte=false, cleanStart=true, willMessage=null, userName=mura-iot.azure-devices.net/dio/?api-version=2021-04-12, password=[83, 104, 97, 114, 101, 100, 65, 99, 99, 101, 115, 115, 83, 105, 103, 110, 97, 116, 117, 114, 101, 32, 115, 114, 61, 97, 108, 118, 105, 110, 45, 105, 111, 116, 46, 97, 122, 117, 114, 101, 45, 100, 101, 118, 105, 99, 101, 115, 46, 110, 101, 116, 37, 50, 70, 100, 101, 118, 105, 99, 101, 115, 37, 50, 70, 100, 105, 111, 100, 101, 38, 115, 105, 103, 61, 79, 37, 50, 66, 56, 67, 106, 117, 65, 88, 66, 101, 97, 106, 103, 101, 101, 56, 121, 51, 90, 97, 112, 103, 97, 65, 122, 66, 107, 109, 88, 57, 37, 50, 70, 87, 113, 88, 122, 76, 85, 66, 122, 114, 71, 104, 89, 37, 51, 68, 38, 115, 101, 61, 49, 55, 51, 54, 49, 52, 57, 50, 56, 57], keepAliveInterval=60, willDestination=null, mqttVersion=5]
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientState notifySentBytes
FINE: dio: sent bytes count=14
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientState notifySentBytes
FINE: dio: sent bytes count=207
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.wire.MqttOutputStream write
FINE: dio: Sent MqttConnect [properties=MqttProperties [validProperties=[17, 24, 33, 39, 34, 25, 23, 38, 21, 22]], willProperties=MqttProperties [validProperties=[24, 1, 2, 8, 9, 38, 3]], info=0, clientId=dio, reservedByte=false, cleanStart=true, willMessage=null, userName=mura-iot.azure-devices.net/dio/?api-version=2021-04-12, password=[83, 104, 97, 114, 101, 100, 65, 99, 99, 101, 115, 115, 83, 105, 103, 110, 97, 116, 117, 114, 101, 32, 115, 114, 61, 97, 108, 118, 105, 110, 45, 105, 111, 116, 46, 97, 122, 117, 114, 101, 45, 100, 101, 118, 105, 99, 101, 115, 46, 110, 101, 116, 37, 50, 70, 100, 101, 118, 105, 99, 101, 115, 37, 50, 70, 100, 105, 111, 100, 101, 38, 115, 105, 103, 61, 79, 37, 50, 66, 56, 67, 106, 117, 65, 88, 66, 101, 97, 106, 103, 101, 101, 56, 121, 51, 90, 97, 112, 103, 97, 65, 122, 66, 107, 109, 88, 57, 37, 50, 70, 87, 113, 88, 122, 76, 85, 66, 122, 114, 71, 104, 89, 37, 51, 68, 38, 115, 101, 61, 49, 55, 51, 54, 49, 52, 57, 50, 56, 57], keepAliveInterval=60, willDestination=null, mqttVersion=5]
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientState notifySent
FINE: dio: key=Con
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.Token notifySent
FINE: dio: > key=Con
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientState get
FINE: dio: wait for new work or for space in the inflight window
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsReceiver run
FINE: dio: Stopping due to IOException
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientComms shutdownConnection
FINE: dio: state=DISCONNECTING
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsCallback stop
FINE: dio: stopping
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsCallback stop
FINE: dio: notify workAvailable and wait for run
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsCallback stop
FINE: dio: stopped
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsCallback run
FINE: dio: notify spaceAvailable
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsReceiver stop
FINE: dio: stopping
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsReceiver stop
FINE: dio: stopped
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsTokenStore quiesce
FINE: dio: resp=Client is currently disconnecting (32102)
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientComms handleOldTokens
FINE: dio: >
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientState resolveOldTokens
FINE: dio: reason Connection lost (32109) - java.io.EOFException
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsTokenStore getOutstandingTokens
FINE: dio: >
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsTokenStore removeToken
FINE: dio: key=Con
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientState disconnected
FINE: dio: disconnected
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientState clearState
FINE: dio: >
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsTokenStore clear
FINE: dio: > 0 tokens
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientState clearConnectionState
FINE: dio: Clearing Connection State (Topic Aliases)
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsSender stop
FINE: dio: stopping sender
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientState notifyQueueLock
FINE: dio: notifying queueLock holders
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsSender stop
FINE: dio: stopped
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientState get
FINE: dio: new work or ping arrived
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.TimerPingSender stop
FINE: dio: stop
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientState get
FINE: dio: no outstanding flows and not connected
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientComms shutdownConnection
FINE: dio: state=DISCONNECTED
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsSender run
FINE: dio: get message returned null, stopping}
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsCallback handleActionComplete
FINE: dio: callback and notify for key=Con
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsSender run
FINE: dio: <
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.Token notifyComplete
FINE: dio: >key=Con response=null excep=Connection lost (32109) - java.io.EOFException
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsCallback fireActionEvent
FINE: dio: call onSuccess key=Con
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.Token markComplete
FINE: dio: >key=null response=null excep=Connection lost (32109) - java.io.EOFException
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.Token notifyComplete
FINE: dio: >key=null response=null excep=Connection lost (32109) - java.io.EOFException
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsReceiver run
FINE: dio: <
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.Token waitForResponse
FINE: dio: failed with exception
Connection lost (32109) - java.io.EOFException
at org.eclipse.paho.mqttv5.client.internal.CommsReceiver.run(CommsReceiver.java:196)
at java.lang.Thread.run(Thread.java:750)
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)
at org.eclipse.paho.mqttv5.client.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:96)
at org.eclipse.paho.mqttv5.client.internal.CommsReceiver.run(CommsReceiver.java:139)
... 1 more
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.MqttAsyncClient disconnect
FINE: dio: > quiesceTimeout=5,000 userContext=null callback=null
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.ClientComms disconnect
FINE: dio: failed: already disconnected
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.MqttAsyncClient disconnect
FINE: dio: < exception
Client is disconnected (32101)
at org.eclipse.paho.mqttv5.client.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:32)
at org.eclipse.paho.mqttv5.client.internal.ClientComms.disconnect(ClientComms.java:554)
at org.eclipse.paho.mqttv5.client.MqttAsyncClient.disconnect(MqttAsyncClient.java:842)
at org.eclipse.paho.mqttv5.client.MqttAsyncClient.disconnect(MqttAsyncClient.java:818)
at mqPackage.MQTTConnection.closeConnection(MQTTConnection.java:242)
at mqPackage.MQTTConnection.connect(MQTTConnection.java:270)
at mqPackage.MQTTHandler.run(MQTTHandler.java:1016)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:750)
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.MqttAsyncClient close
FINE: dio: <
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.internal.CommsTokenStore clear
FINE: dio: > 0 tokens
Oct 09, 2024 11:59:03 AM org.eclipse.paho.mqttv5.client.MqttAsyncClient close
FINE: dio: >
I have the following codes:
Код: Выделить всё
public void setConOpts() throws Exception {
m_conOpts.setServerURIs(new String[] { m_ip });
if (m_userNameAuth) {
m_conOpts.setUserName(m_username);
m_conOpts.setPassword(m_password.getBytes());
}
m_conOpts.setConnectionTimeout(300);
m_conOpts.setCleanStart(m_setCleanStart);
if (m_trustServerCert || m_validateServerCert || m_twoWaySSL) {
m_conOpts.setSocketFactory(TLS.getSocketFactory(m_trustServerCert, m_validateServerCert, m_serverCertPath, m_twoWaySSL, m_keystorePath, m_keystorePwd));
}
}
Код: Выделить всё
this.v5Client = new MqttAsyncClient(m_ip, m_clientID, m_persistence);
this.v5Client.setCallback(mqH);
IMqttToken connectToken = this.v5Client.connect(m_conOpts);
connectToken.waitForCompletion(actionTimeout);
https://learn.microsoft.com/en-us/azure ... to-iot-hub
*Имя пользователя и пароль в журнале отладки не являются действительными
Подробнее здесь: https://stackoverflow.com/questions/790 ... re-iot-hub