Skip to content
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

RPC responses with no dst get stuck in the outgoing queue #4

Open
andrey-hinkov opened this issue Jun 7, 2021 · 2 comments
Open

RPC responses with no dst get stuck in the outgoing queue #4

andrey-hinkov opened this issue Jun 7, 2021 · 2 comments
Assignees

Comments

@andrey-hinkov
Copy link

How to reproduce:

Invoke a RPC method over MQTT but don't provide src key in the request frame, for example:

{ "id": 1, "method": "Sys.GetUID"}

The call will get executed, but since dst is unknown, mg_rpc_channel_mqtt_send_frame() will fail, as expected:

[Jun  7 14:21:35.338] mgos_rpc_channel_mq:129 Cannot reply to RPC over MQTT, no dst: [{"id":1,"src":"shelly4pro-f008d1db58a0","result":{"pid": "mos", "app": "FourPro", "uid": "0f3abe5700799b62"}}]
[Jun  7 14:21:35.355] mg_rpc.c:636            0x3ffd6e3c SEND FRAME (109): {"id":1,"src":"shelly4pro-f008d1db58a0","result":{"pid": "mos", "app": "FourPro", "uid": "0f3abe5700799b62"}} -> 0

The problem is that mg_rpc_dispatch_frame() will queue the response anyway, despite the fact it can actually never be sent, which means it'll get stuck in the queue:

[Jun 7 14:21:35.369] mg_rpc.c:655 QUEUED FRAME (109): {"id":1,"src":"shelly4pro-f008d1db58a0","result":{"pid": "mos", "app": "FourPro", "uid": "0f3abe5700799b62"}}

Eventually, such bad incoming requests can fill the queue with "dead" responses:

[Jun  7 14:22:59.774] mgos_rpc_channel_mq:129 Cannot reply to RPC over MQTT, no dst: [{"id":1,"src":"shelly4pro-f008d1db58a0","result":{"pid": "mos", "app": "FourPro", "uid": "0f3abe5700799b62"}}]
[Jun  7 14:22:59.788] mg_rpc.c:636            0x3ffd6e3c SEND FRAME (109): {"id":1,"src":"shelly4pro-f008d1db58a0","result":{"pid": "mos", "app": "FourPro", "uid": "0f3abe5700799b62"}} -> 0
[Jun  7 14:22:59.804] mgos_rpc_channel_mq:129 Cannot reply to RPC over MQTT, no dst: [{"id":2,"src":"shelly4pro-f008d1db58a0","result":{"pid": "mos", "app": "FourPro", "uid": "0f3abe5700799b62"}}]
[Jun  7 14:22:59.819] mg_rpc.c:636            0x3ffd6e3c SEND FRAME (109): {"id":2,"src":"shelly4pro-f008d1db58a0","result":{"pid": "mos", "app": "FourPro", "uid": "0f3abe5700799b62"}} -> 0
[Jun  7 14:22:59.833] mgos_rpc_channel_mq:129 Cannot reply to RPC over MQTT, no dst: [{"id":3,"src":"shelly4pro-f008d1db58a0","result":{"pid": "mos", "app": "FourPro", "uid": "0f3abe5700799b62"}}]
[Jun  7 14:22:59.849] mg_rpc.c:636            0x3ffd6e3c SEND FRAME (109): {"id":3,"src":"shelly4pro-f008d1db58a0","result":{"pid": "mos", "app": "FourPro", "uid": "0f3abe5700799b62"}} -> 0
[Jun  7 14:22:59.864] mgos_rpc_channel_mq:129 Cannot reply to RPC over MQTT, no dst: [{"id":4,"src":"shelly4pro-f008d1db58a0","result":{"pid": "mos", "app": "FourPro", "uid": "0f3abe5700799b62"}}]
[Jun  7 14:22:59.881] mg_rpc.c:636            0x3ffd6e3c SEND FRAME (109): {"id":4,"src":"shelly4pro-f008d1db58a0","result":{"pid": "mos", "app": "FourPro", "uid": "0f3abe5700799b62"}} -> 0
[Jun  7 14:22:59.894] mgos_rpc_channel_mq:129 Cannot reply to RPC over MQTT, no dst: [{"id":5,"src":"shelly4pro-f008d1db58a0","result":{"pid": "mos", "app": "FourPro", "uid": "0f3abe5700799b62"}}]
[Jun  7 14:22:59.908] mg_rpc.c:636            0x3ffd6e3c SEND FRAME (109): {"id":5,"src":"shelly4pro-f008d1db58a0","result":{"pid": "mos", "app": "FourPro", "uid": "0f3abe5700799b62"}} -> 0
@rojer rojer self-assigned this Jun 17, 2021
@rojer
Copy link
Contributor

rojer commented Jun 17, 2021

interesting. i think we may not even want to admit a request via mqtt that requires a response (has id) but does not provide src

@iliapenev
Copy link
Contributor

iliapenev commented Jun 18, 2021

Please check pull request #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants