W5100S MQTT Yield 문의
Ethernet Chips
- MQTT
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: W5100S MQTT Yield 문의
by WIZnet AI AI generated ·
RE: W5100S MQTT Yield 문의
by matthew WIZnet ·
안녕하세요. 어떤 환경에서 어느 라이브러리를 사용하여 개발 중인지 알 수 있을까요?
RE: W5100S MQTT Yield 문의
by TheoIm WIZnet ·
The issue you're facing is that the
mqtt_transport_yieldfunction blocks for a significant amount of time (10 seconds) when there are no incoming messages on the subscribed topic, preventing you from publishing messages during this period.To address this issue, you can modify the implementation to reduce the blocking time. Here are some approaches:
Reduce the Timeout Duration: Adjust the timeout value for the
mqtt_transport_yieldcall to a shorter period. This will allow the function to return control more quickly, enabling you to perform other tasks such as publishing.int MQTTYield(MQTTClient* c, int timeout_ms){int rc = SUCCESSS;Timer timer;TimerInit(&timer);TimerCountdownMS(&timer, timeout_ms); // Consider using a smaller timeout valueint cycle_timeout_ms = 100; // Adjust this value as neededwhile (!TimerIsExpired(&timer)) {if (cycle(c, &timer) == FAILURE) {rc = FAILURE;break;}// Adjust cycle timing to avoid blocking for too longTimerCountdownMS(&timer, cycle_timeout_ms);}return rc;}Non-Blocking Calls: If reducing the timeout is not sufficient, consider using non-blocking I/O or implementing a mechanism to check for messages without blocking. This may require modifying the MQTT library to support non-blocking operations.
Background Task: Offload the MQTT yield process to a background task or a separate thread, allowing the main thread to handle publishing. This way, the main thread remains responsive, and you can still receive messages in the background.
// Example of running the yield in a separate threadvoid* mqtt_yield_task(void* arg) {MQTTClient* client = (MQTTClient*)arg;while (1) {MQTTYield(client, 100); // Run with a short timeout}return NULL;} // In the main function, start the background taskpthread_t thread;pthread_create(&thread, NULL, mqtt_yield_task, (void*)&client); // The main thread can now handle publishingManual Message Handling: Instead of relying on
mqtt_transport_yieldfor processing, you can implement manual message handling by periodically calling a non-blocking version ofcycle. This allows you to control when and how long to check for messages.If none of these options fully resolve the issue, you may need to delve deeper into the MQTT library to optimize or customize the behavior according to your specific needs.
RE: W5100S MQTT Yield 문의
by pmjqpt ·
SSL_RECV_TIMEOUT 이 값을 변경해보세요. MQTT timeout 값만 변경해도 안되었는데 이 값 변경하니까 저는 해결되었습니다