actix-web icon indicating copy to clipboard operation
actix-web copied to clipboard

broken pipe when downloading data using low bandwidth ( http2 )

Open fbucek opened this issue 3 years ago • 5 comments

With new Actix-web 4.0.x with https ( http2 ) our devices with low bandwidth connection can not download 20-30MB binary data from acitx_web server. Devices reported error like: broken pipe connection reset

When using low bandwidth connection downloading data form actix_web server fail with e.g.:

* Failed receiving HTTP2 data
* LibreSSL SSL_write: Broken pipe, errno 32
* Failed sending HTTP2 data

Steps to Reproduce

  1. Get actix example https://github.com/actix/examples/tree/master/https-tls/rustls and run it cargo run
  2. Copy cca 20MB file big_file into static folder
  3. run curl with rate limiter: curl --limit-rate 100k -v 'https://localhost:8443/static/big_file' --insecure > test
  7 26.9M    7 1968k    0     0    99k      0  0:04:35  0:00:19  0:04:16   99k* LibreSSL SSL_read: Connection reset by peer, errno 54
* Failed receiving HTTP2 data
* LibreSSL SSL_write: Broken pipe, errno 32
* Failed sending HTTP2 data
  7 26.9M    7 1984k    0     0   100k      0  0:04:33  0:00:19  0:04:14  103k
* Connection #0 to host localhost left intact
curl: (56) LibreSSL SSL_read: Connection reset by peer, errno 54
(base) 

Note: - Without argument --limit-rate 100k -> it works as expected. - http works as expected ( just https is problem ) - devices using reqwest rust crate not curl to download data. Same result.

Context

Downloading binary data from actix-web server. ( program updates )

Your Environment

Production environment: raspberry pi ( arm ) Dev environment: macOS

  • Rust Version (I.e, output of rustc -V): rustc 1.59.0
  • Actix Web Version: 4.0.1

fbucek avatar Mar 12 '22 07:03 fbucek

Huh that is weird. I'll have a go using h2 and/or rustls directly and see how it behaves.

robjtede avatar Mar 15 '22 18:03 robjtede

Could you please give us any update on this issue. Were you able to reproduce this bug? Thanks in advance.

fbucek avatar Mar 23 '22 11:03 fbucek

A manual re-creation of the h2 + rustls does not result in broken pipe errors so there is almost certainly a hidden bug.

robjtede avatar Mar 27 '22 00:03 robjtede

Bug relates to ping-pong behavior when pong frames are not sent back from client. Workaround for this issue is to set .keep_alive(None) (or just higher interval) which controls ping-pong frequency.

I would also dare to say it's possible that cURL and/or reqwest or one their dependencies does not send h2 pong replies and needs changes. Needs more investigation though.

robjtede avatar Mar 27 '22 18:03 robjtede

It's often more about default behavior rather than support. Some libs may consider ping-pong an opt-in feature. I don't know what people prefer regarding this matter but as actix-web by default handling http1 and http2 in the same way at high level it makes more sense to me that keep-alive feature should include h2 ping-pong. Otherwise explicit http2 configuration exposed through httpserver is an alternative.

fakeshadow avatar Apr 01 '22 16:04 fakeshadow