Skip to content

Commit 9aa64bf

Browse files
committed
fix: fixed header of AUTH packet
Associated with contributions from #980 #981 Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>
1 parent bd291f1 commit 9aa64bf

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/client/internal/ClientComms.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.eclipse.paho.mqttv5.common.MqttException;
4242
import org.eclipse.paho.mqttv5.common.MqttMessage;
4343
import org.eclipse.paho.mqttv5.common.MqttPersistenceException;
44+
import org.eclipse.paho.mqttv5.common.packet.MqttAuth;
4445
import org.eclipse.paho.mqttv5.common.packet.MqttConnAck;
4546
import org.eclipse.paho.mqttv5.common.packet.MqttConnect;
4647
import org.eclipse.paho.mqttv5.common.packet.MqttDisconnect;
@@ -176,8 +177,9 @@ void internalSend(MqttWireMessage message, MqttToken token) throws MqttException
176177
public void sendNoWait(MqttWireMessage message, MqttToken token) throws MqttException {
177178
final String methodName = "sendNoWait";
178179

179-
if (isConnected() || (!isConnected() && message instanceof MqttConnect)
180-
|| (isDisconnecting() && message instanceof MqttDisconnect)) {
180+
if (isConnected() ||
181+
(!isConnected() && (message instanceof MqttConnect || message instanceof MqttAuth)) ||
182+
(isDisconnecting() && message instanceof MqttDisconnect)) {
181183

182184
if (disconnectedMessageBuffer != null && disconnectedMessageBuffer.getMessageCount() != 0) {
183185
// @TRACE 507=Client Connected, Offline Buffer available, but not empty. Adding

org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/client/internal/ClientState.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,8 +841,15 @@ protected MqttWireMessage get() throws MqttException {
841841
// Handle the case where not connected. This should only be the case if:
842842
// - in the process of disconnecting / shutting down
843843
// - in the process of connecting
844-
if (pendingFlows == null || (!connected && (pendingFlows.isEmpty()
845-
|| !((MqttWireMessage) pendingFlows.elementAt(0) instanceof MqttConnect)))) {
844+
if (pendingFlows == null ||
845+
(!connected &&
846+
(pendingFlows.isEmpty() ||
847+
!( ( pendingFlows.elementAt(0) instanceof MqttConnect) ||
848+
( pendingFlows.elementAt(0) instanceof MqttAuth)
849+
)
850+
)
851+
)
852+
){
846853
// @TRACE 621=no outstanding flows and not connected
847854
log.fine(CLASS_NAME, methodName, "621");
848855

org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/common/packet/MqttAuth.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ protected byte[] getVariableHeader() throws MqttException {
104104

105105
@Override
106106
protected byte getMessageInfo() {
107-
return (byte) (1);
107+
return (byte) (0);
108108
}
109109

110110
public int getReturnCode() {

0 commit comments

Comments
 (0)