-
Notifications
You must be signed in to change notification settings - Fork 266
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
Non-blocking receive never notifies #820
Comments
hey, thanks for reporting. in case 3, you can increase the timeout duration, e.g. for case 2, i will get back to you! |
Requests take a while to be processed, so both We require a sync specific |
From a users perspective the timeout in If For now I moved the let (mut client, mut connection) = Client::new(mqttoptions, 100);
let (send_event, recv_event)= std::sync::mpsc::channel();
std::thread::spawn(move || {
for notification in connection.iter() {
send_event.send(notification).unwrap();
}
});
...
loop {
if let Ok(notification) = recv_event.try_recv() {
println!("Notification = {:?}", notification);
}
} Maybe it is possible to do something similar in the |
Just wanted to ping on this item. I'm fairly new to Rust and am using an MQTT (bee hive monitoring) project for learning. Which is why I avoided the async stuff for now as I figured the sync approach would be easier and more straight forward for learning. And it would be an excuse to use channels for cross thread communication. I've been spinning on this for a while. I've assumed it was me incorrectly using the APIs or something silly I've missed. I've been using recv_timeout with 250ms, believing that would be plenty. Honestly never see a situation where it's not relatively eons. Apparently not. I finally reached the point where I figured it must be a bug in the library and I found this report. I can confirm things work with 1 second timeouts. Perhaps a documentation mention (perhaps I missed it?) that less than 1 second timeouts is not supported? Or perhaps the implementation can do a min/max to clamp the smallest timeout to whatever you guys determine works reliably? And a note that try_recv is completely broken and doesn't work? Will offer, my approach is fairly close to what OP stated he is doing. Seemingly we've traveled the same path. Thanks for the lib. Pretty easy to use once the nit here and there is understood. I'm sure this fix will significantly raise my enjoyment on the learning curve here. |
Expected Behavior
Expected case 1, 2 and 3 to print the same notifications.
Current Behavior
Only case 1 prints notifications, case 2 and 3 show no notifications.
Context
Trying to integrate non-blocking receive into an existing event loop. But
try_recv()
andrecv_timeout()
never generate meaning full notifications.recv()
does generate notifications, but is blocking.The text was updated successfully, but these errors were encountered: