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

One second buffer #3

Open
gpabdo opened this issue Oct 27, 2023 · 3 comments
Open

One second buffer #3

gpabdo opened this issue Oct 27, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@gpabdo
Copy link

gpabdo commented Oct 27, 2023

It seems messages are put into a queue and held for up to 1 second. I see this in the debug logs received received received before I see about to send a message about to send a message about to send a message no matter what the rate from the serial device to 2mqtt it is holding those messages and shipping them off every 1 second.

2023-10-27T13:36:58.894+0530	debug	adapter/service.go:172	received a message from source device	{"message": "{data:{\"message\":\"metrics\",\"uptime\":46028069,\"altitude\":1072.49,\"pressure\":97675.58,\"temp\":71.66,\"heading\":83.83,\"accelX\":26.47,\"accelY\":-63.31,\"accelZ\":993.08,\"gyroX\":26.47,\"gyroY\":-63.31,\"gyroZ\":993.08}\r, others:map[], timestamp:2023-10-27 13:36:58.894284234 +0530 IST m=+2.317788558", "adapterName": "adapter1", "provider": "raw"}
2023-10-27T13:36:59.225+0530	debug	adapter/service.go:172	received a message from source device	{"message": "{data:{\"message\":\"metrics\",\"uptime\":46028402,\"altitude\":1072.62,\"pressure\":97675.14,\"temp\":71.66,\"heading\":83.98,\"accelX\":26.35,\"accelY\":-63.56,\"accelZ\":993.32,\"gyroX\":26.35,\"gyroY\":-63.56,\"gyroZ\":993.32}\r, others:map[], timestamp:2023-10-27 13:36:59.224778851 +0530 IST m=+2.648283101", "adapterName": "adapter1", "provider": "raw"}
2023-10-27T13:36:59.556+0530	debug	adapter/service.go:172	received a message from source device	{"message": "{data:{\"message\":\"metrics\",\"uptime\":46028735,\"altitude\":1072.85,\"pressure\":97675.38,\"temp\":71.66,\"heading\":83.46,\"accelX\":26.35,\"accelY\":-63.68,\"accelZ\":993.32,\"gyroX\":26.35,\"gyroY\":-63.68,\"gyroZ\":993.32}\r, others:map[], timestamp:2023-10-27 13:36:59.555906296 +0530 IST m=+2.979410564", "adapterName": "adapter1", "provider": "raw"}
2023-10-27T13:36:59.682+0530	debug	mqtt/device.go:134	about to send a message	{"adapterName": "adapter1", "message": "{data:{\"message\":\"metrics\",\"uptime\":46028069,\"altitude\":1072.49,\"pressure\":97675.58,\"temp\":71.66,\"heading\":83.83,\"accelX\":26.47,\"accelY\":-63.31,\"accelZ\":993.08,\"gyroX\":26.47,\"gyroY\":-63.31,\"gyroZ\":993.08}\r, others:map[mqtt_qos:0 mqtt_topic:], timestamp:2023-10-27 13:36:58.894284234 +0530 IST m=+2.317788558"}
2023-10-27T13:36:59.682+0530	debug	mqtt/device.go:134	about to send a message	{"adapterName": "adapter1", "message": "{data:{\"message\":\"metrics\",\"uptime\":46028402,\"altitude\":1072.62,\"pressure\":97675.14,\"temp\":71.66,\"heading\":83.98,\"accelX\":26.35,\"accelY\":-63.56,\"accelZ\":993.32,\"gyroX\":26.35,\"gyroY\":-63.56,\"gyroZ\":993.32}\r, others:map[mqtt_qos:0 mqtt_topic:], timestamp:2023-10-27 13:36:59.224778851 +0530 IST m=+2.648283101"}
2023-10-27T13:36:59.683+0530	debug	mqtt/device.go:134	about to send a message	{"adapterName": "adapter1", "message": "{data:{\"message\":\"metrics\",\"uptime\":46028735,\"altitude\":1072.85,\"pressure\":97675.38,\"temp\":71.66,\"heading\":83.46,\"accelX\":26.35,\"accelY\":-63.68,\"accelZ\":993.32,\"gyroX\":26.35,\"gyroY\":-63.68,\"gyroZ\":993.32}\r, others:map[mqtt_qos:0 mqtt_topic:], timestamp:2023-10-27 13:36:59.555906296 +0530 IST m=+2.979410564"}

I have tried setting transmit_pre_delay: 10ms and also 0s on the MQTT side, so I don't think this is where the delay is being introduced.

Is any way to disable this queueing and ship then immediately?

Thanks!

@jkandasa
Copy link
Member

hi @gpabdo thanks to report this issue.
I do not think we have a delay in message queue. The message queue is acting as buffer. I have modified the time.sleep to act on a valid values. If you set 0s this sleep will be skipped. this change is available in the main branch https://github.com/mycontroller-org/2mqtt/releases/tag/development

I will have a look into the queue code and fix it if I find a delay there.

@jkandasa
Copy link
Member

@gpabdo found the root cause, the issue is introduced in b0f46c1 to fix #1

I have to rewrite the queue package.

@jkandasa jkandasa added the bug Something isn't working label Oct 27, 2023
@jkandasa
Copy link
Member

@gpabdo this issue partially fixed on 546d5cd#diff-46374e5bbfeba39b9d47c02934dd4cf9e5f05bd2120ee837c8a0a8d0f73e5511

However now, the messages will not be kept on buffer, if the target device is not in up state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants