wolfSSL / wolfMQTT

wolfMQTT is a small, fast, portable MQTT client implementation, including support for TLS 1.3.
https://www.wolfssl.com
GNU General Public License v2.0
518 stars 156 forks source link

MqttClient_WaitType 死锁的问题 #383

Closed yunhui0501 closed 7 months ago

yunhui0501 commented 7 months ago

在MqttClient_WaitType的这个函数中 case MQTT_MSG_BEGIN: 这个分支中 执行: rc = wm_SemLock(&client->lockRecv); 后面没有执行 wm_SemUnlock(&client->lockRecv); 导致卡住。

MqttClient_WaitType有几个地方直接返回了, 但是并没有执行wm_SemUnlock(&client->lockRecv);

大家是碰到这样的问题没有,如何解决的 ?

yunhui0501 commented 7 months ago

if (rc == MQTT_CODE_CONTINUE && mms_stat->read > MQTT_MSG_WAIT) { wm_SemUnlock(&client->lockRecv); //在这里增加,但是仍然有问题 return rc; }

新的问题就是 :在

ifdef WOLFMQTT_NONBLOCK

/* if nonblocking and some data has been read, do not release read lock */
if (rc == MQTT_CODE_CONTINUE && mms_stat->read > MQTT_MSG_WAIT) 

会产生下面这个错误 Error: Error (Out of buffer)

embhorn commented 7 months ago

Hello @yunhui0501

Thanks for contacting wolfSSL Support. Could you please share some more details about this issue? Please enable debug logging by defining WOLFMQTT_DEBUG_TRACE and WOLFMQTT_DEBUG_CLIENT and share the log as a file.

Is this reproducible using the non-blocking client example? If not, please share the application code.

If you would prefer to keep these details private, please open a support ticket by emailing support@wolfssl.com

Kind regards, Eric - wolfSSL Support

yunhui0501 commented 7 months ago

Hello @embhorn Thank you for your reply.

The usage scenario where this abnormal situation occurs: the packet size of both publishing and subscribing messages reaches 100K, with continuous production and consumption information, and the generation of deadlocks is random.

Please refer to the attachment for the location of the code deadlock.

embhorn commented 7 months ago

Hi @yunhui0501

I do not see the attachment you are referring to. Please also share the debug logs I requested.

embhorn commented 7 months ago

Also, are you using the latest version of the library?

yunhui0501 commented 7 months ago

Hello @embhorn #define LIBWOLFMQTT_VERSION_STRING "1.13.0"

embhorn commented 7 months ago

@yunhui0501

You should definitely update to the latest release. There have been some significant improvements in the non-blocking feature.

yunhui0501 commented 7 months ago

@embhorn Thank you very much for your suggestion. I have switched to the latest version v1.17.1 and it is currently running very well.

embhorn commented 7 months ago

Excellent! I will go ahead and close out this support inquiry. If any other questions come up please do not hesitate to open a new issue anytime by emailing support@wolfssl.com or through the zendesk portal at https://wolfssl.zendesk.com/. We are always happy to help out in any way we can.

Until next time all the best and thank you for using wolfSSL support.

Warmest Regards,