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

Network(KeepAlive(Elapsed(()))) Error #926

Open
srikruth-reddy-b opened this issue Nov 29, 2024 · 4 comments
Open

Network(KeepAlive(Elapsed(()))) Error #926

srikruth-reddy-b opened this issue Nov 29, 2024 · 4 comments

Comments

@srikruth-reddy-b
Copy link

Hello all,
I am facing an issue while trying to connect a rumqttc client (running on Windows) to a rumqttd MQTT broker (running on Linux). The connection attempt fails with the following error message:
Error while handling MQTT connect packet, error: Network(KeepAlive(Elapsed(())))

2024-11-29T09:16:59.816505Z INFO rumqttd::server::broker: accept, name: "v5-1", addr: 192.168.0.103:36717, count: 0, tenant: None
2024-11-29T09:16:59.817980Z ERROR rumqttd::server::broker: Error while handling MQTT connect packet, error: Network(KeepAlive(Elapsed(())))
in rumqttd::server::broker::remote_link with tenant_id: None

2024-11-29T09:22:55.863240Z INFO rumqttd::server::broker: accept, name: "v4-1", addr: 192.168.0.103:36775, count: 0, tenant: None
2024-11-29T09:22:55.864706Z ERROR rumqttd::server::broker: Error while handling MQTT connect packet, error: Network(KeepAlive(Elapsed(())))
in rumqttd::server::broker::remote_link with tenant_id: None

2024-11-29T09:24:15.428913Z INFO rumqttd::server::broker: accept, name: "ws-1", addr: 192.168.0.103:36789, count: 0, tenant: None
2024-11-29T09:24:15.522176Z ERROR rumqttd::server::broker: Error while handling MQTT connect packet, error: Network(KeepAlive(Elapsed(())))
in rumqttd::server::broker::websocket_link

I have confirmed that both the client and broker are on the same local network.
I have tested multiple ports: 1883, 1884, and 8083 on the broker side, but the issue persists.
I also checked the firewall configurations on the Linux machine, and the necessary ports are open.

@swanandx
Copy link
Member

hey @srikruth-reddy-b , are you polling the eventloop in rumqttc? You must poll it to make progress, which also includes sending pings!

Keep alive Elapsed error comes when client doesn't send ping requests within keepalive interval

@srikruth-reddy-b
Copy link
Author

Yes @swanandx, iam polling the eventloop

 loop {
        let event = eventloop.poll().await;
        match event {
            Ok(_v) => {
                println!("Event = {v:?}");
            } 
            Err(e) => {
                println!("Error = {:?}",e);
                return Ok(());
            }
        }
    }

@swanandx
Copy link
Member

can you please provide a minimal poc, if possible, along with versions of rumqttc & rumqttd you are using with config, thanks!

@srikruth-reddy-b
Copy link
Author

srikruth-reddy-b commented Nov 29, 2024

rumqttc = { version = "0.24", features = ["websocket"] }

name = "rumqttd"
version = "0.19.0"
let mut mqtt_options = MqttOptions::new("client", "192.168.0.137", 1883);
 mqtt_options.set_clean_session(true);
 mqtt_options.set_keep_alive(Duration::from_secs(180));
 let (client, mut eventloop) = AsyncClient::new(mqtt_options, 10);

 task::spawn(async move {
   let payload = "hello";
   loop {
      if let Err(e) = client.publish("hello/world", QoS::AtLeastOnce, false, payload.to_string()).await {
         eprintln!("Failed to send message {}: {:?}", i, e);
     }
     else {
         sleep(Duration::from_millis(10)); 
     }
  } 
 });

 loop {
     let event = eventloop.poll().await;
     match event {
         Ok(_v) => {
             println!("Event = {v:?}");
         } 
         Err(e) => {
             println!("Error = {:?}",e);
             return Ok(());
         }
     }
 }

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

2 participants