lindenlab / caddy-s3-proxy

s3 proxy plugin for caddy
Apache License 2.0
72 stars 22 forks source link

Connection reset by peer puts caddy in an unrecoverable state #49

Open nikooo777 opened 3 years ago

nikooo777 commented 3 years ago

While trying out this extension I encountered an issue with a video object on S3 (wasabi) that doesn't seem to have a content-length attached to it or something. It will download fine via wget, but if either that gets interrupted mid way of if the object is accessed through a browser, the extension will error with this:

Aug 18 01:16:58 live-transcoder caddy[784387]: {"level":"error","ts":1629249418.7785132,"logger":"http.log.error","msg":"write tcp *********:443->*********:55986: write: connection reset by peer","request":{"remote_addr":"*********:55986","proto":"HTTP/1.1","method":"GET","host":"host.name.here","uri":"/odysee-replay/e4fa7fae428ac954bdac1ffda560de9bf716b6b3_odysee_1628887004.mp4","headers":{"Accept":["*/*"],"Accept-Encoding":["identity"],"Connection":["Keep-Alive"],"User-Agent":["Wget/1.19.4 (linux-gnu)"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"","proto_mutual":true,"server_name":"host.name.here"}},"duration":50.691332768,"status":500,"err_id":"ktwhmm7hh","err_trace":"caddy-s3-proxy.S3Proxy.ServeHTTP (s3proxy.go:379)"}

which points to this https://github.com/lindenlab/caddy-s3-proxy/blob/95af47dc5fe2e691c40e08f179ba7c3a02721572/s3proxy.go#L379

After that, the server just stops responding until the service is restarted. Restarting caddy implies hard killing the process as well, as something locks up pretty bad and a normal shutdown doesn't seem to work.