diff --git a/src/mqtt_client.c b/src/mqtt_client.c index a13c64325..f284b0207 100644 --- a/src/mqtt_client.c +++ b/src/mqtt_client.c @@ -1087,7 +1087,8 @@ static int MqttClient_WaitType(MqttClient *client, void *packet_obj, if (rc <= 0) { #ifdef WOLFMQTT_NONBLOCK if (rc == MQTT_CODE_CONTINUE && - client->packet.stat > MQTT_PK_BEGIN) { + (client->packet.stat > MQTT_PK_BEGIN || + client->read.total > 0)) { /* advance state, since we received some data */ mms_stat->read = MQTT_MSG_HEADER; } diff --git a/src/mqtt_packet.c b/src/mqtt_packet.c index cafa8e842..1b9fd0008 100644 --- a/src/mqtt_packet.c +++ b/src/mqtt_packet.c @@ -1963,7 +1963,6 @@ int MqttPacket_Read(MqttClient *client, byte* rx_buf, int rx_buf_len, { case MQTT_PK_BEGIN: { - client->read.pos = 0; client->packet.header_len = MQTT_PACKET_HEADER_MIN_SIZE; client->packet.remain_len = 0;