ory / oathkeeper

A cloud native Identity & Access Proxy / API (IAP) and Access Control Decision API that authenticates, authorizes, and mutates incoming HTTP(s) requests. Inspired by the BeyondCorp / Zero Trust white paper. Written in Go.
https://www.ory.sh/?utm_source=github&utm_medium=banner&utm_campaign=hydra
Apache License 2.0
3.23k stars 355 forks source link

SSE writes are ignored by timeout settings #877

Open andrewbanchich opened 2 years ago

andrewbanchich commented 2 years ago

Preflight checklist

Describe the bug

serve.proxy.timeout.write will close server-sent event connections, even if they are using keep-alives.

Reproducing the bug

  1. Create server with SSE endpoint and keep-alives sent every 15 seconds.
  2. On the frontend, use the JS EventSource API to connect and process messages.
  3. The browser console should display an error after Oathkeeper's timeout setting (120s by default) saying the connection was closed.

Relevant log output

No response

Relevant configuration

No response

Version

0.38.15-beta.1

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Docker

Additional Context

No response

aeneasr commented 2 years ago

Hm yeah I think Oathkeeper really struggles with SSE. I think one option is to increase the timeout values. However, it will still close at some point.

Maybe we could implement keep alive somehow?

andrewbanchich commented 2 years ago

Yeah, having keep-alive would be ideal and allow Oathkeeper to differentiate between a working SSE connection and one that needs to be closed.

andlinger commented 1 year ago

Maybe it is possible to simply suspend the timeout if the content type is "text/event-stream".