Explicit 5-second timeout to ureq

main
Nick Thomas 2022-10-18 20:37:47 +01:00
parent 0b9840669e
commit 77f52f0b2c
1 changed files with 4 additions and 2 deletions

View File

@ -214,7 +214,9 @@ fn mqtt_connect(uri: String, client_id: String) -> Result<mqtt::Client, mqtt::Er
fn gather(uri: &str, password: &str) -> Result<MQTTData, Error> {
let body = format!("optType=ReadRealTimeData&pwd={}", password);
let response = ureq::post(uri).send_string(&body)?;
let response = ureq::post(uri)
.timeout(Duration::from_secs(5))
.send_string(&body)?;
if response.status() < 200 || response.status() > 299 {
return Err(Error::MyError);
@ -272,7 +274,7 @@ fn main() {
Err(e) => println!("Failed to gather data from inverter: {:?}", e),
};
std::thread::sleep(std::time::Duration::new(5, 0));
std::thread::sleep(std::time::Duration::from_secs(5));
}
mqtt_client.disconnect(None).unwrap();