New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subscribeTimeoutException on shadowUpdate in subscription callback #97
Comments
I'm seeing the same subscribeTimeoutException when using two AWSIoTMQTTShadowClients and the second shadow client tries to update the shadow. I'm wondering if my issue is because the two clients are on separate threads because I haven't had any issue when they run in the same thead. |
Hi @daviian , Thank you for providing the information. Let me rephrase to see if I am understanding your case correctly. You are trying to do the following things:
The problem with it is that, the SDK does not allow synchronous API invocation within message callback. On the first shadow update request, it needs to subscribe to its corresponding shadow accepted/rejected topics, which are synchronous calls, resulting in One thing you can do is to have the shadow update running in a separate thread so that it will not interfere with the callback dispatching. Another thing you can do is to use separate MQTT connections to AWS IoT. In that case, 2 clients are independent and will interfere with each other. Correct me if I am wrong. Hope the above helps. Thanks, |
@liuszeng Thanks for your reply. You are totally right. That's exactly what I want to achieve. As far as I understand now the shadow client is not able to perform asynchronous tasks on the shadow, that's why the only applicable possibilities are your proposed ones. Best regards, |
@daviian |
Hi @daviian , @tbergeltffs is also correct. Using 2 instances of the SDK client would also solve the problem. Keep in mind that the client mainly maintains a MQTT connection and perform shadow operations using that connection. As long as the 2 clients are connected with different client ids, you can use Hope the above helps. Thanks, |
@tbergeltffs @liuszeng At first I had one MQTT client and one shadow client, not sharing the connection. But that lead to the other issue I opened also yesterday (#96). Hopefully you can enlighten me in my confusion ;-) Ok I might have found the answer to all the mystery about clientId 😃 |
Hi @daviian , You are correct. Client id and thing name are totally different things. Client id is there only to accommodate with the MQTT protocol, as a client id is required to establish the connection to AWS IoT. Thing name is more of an identifier in your account to distinguish different shadow JSON docs. Once the connection is established, you can access any shadow JSON docs using that connection. AWS IoT does not allow 2 connections with the same client id. Hope the above helps. Please feel free to re-open the issue if you have further questions. Thanks, |
Scenario
Device connects an AWSIoTMQTTShadowClient and retrieves the used MQTTClient with
getMQTTConnection()
.The device subscribes to a topic on the MQTTClient und performs sensor readings and a shadow update in the callback.
This results in following log output:
First line is from my callback method.
The text was updated successfully, but these errors were encountered: