File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -223,14 +223,18 @@ async fn ping_pong(
223223) {
224224 loop {
225225 let ( buf, len) = ProtoEvent :: Ping . into ( ) ;
226- if let Err ( e) = conn. send ( & buf[ ..len] ) . await {
227- log:: warn!( "{addr}: send error `{e}`, closing connection" ) ;
228- let _ = conn. close ( ) . await ;
229- break ;
230- }
231- log:: trace!( "PING >->->->->- {addr}" ) ;
232226
233- tokio:: time:: sleep ( Duration :: from_millis ( 500 ) ) . await ;
227+ // send 4 pings, at least one must be answered
228+ for _ in 0 ..4 {
229+ if let Err ( e) = conn. send ( & buf[ ..len] ) . await {
230+ log:: warn!( "{addr}: send error `{e}`, closing connection" ) ;
231+ let _ = conn. close ( ) . await ;
232+ break ;
233+ }
234+ log:: trace!( "PING >->->->->- {addr}" ) ;
235+
236+ tokio:: time:: sleep ( Duration :: from_millis ( 500 ) ) . await ;
237+ }
234238
235239 if !ping_response. borrow_mut ( ) . remove ( & addr) {
236240 log:: warn!( "{addr} did not respond, closing connection" ) ;
You can’t perform that action at this time.
0 commit comments