Explicit 5-second timeout to ureq
parent
0b9840669e
commit
77f52f0b2c
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue