How do I pass keepalive: true to ranch_tcp in my Endpoint configuration?

This is a repost of an issue (ReverseProxyPlug and longpoll · Issue #146 · tallarium/reverse_proxy_plug · GitHub) I opened . The forum is probably the better place, so I’ll link back in the issue at some point.

I am not 100% sure if this is an issue concerning Plug, Phoenix or the ReverseProxyPlug.

My setup: I want to proxy a CouchDB 3.2.1 in my Phoenix app, my initial attempt is using ReverseProxyPlug:

  forward "/db", ReverseProxyPlug, upstream: Application.get_env(:my_app, :couchdb_root)

But clients that connect throw an error when listening to changes:

GET http://localhost:4000/db/project_1/_changes?timeout=600000&style=all_docs&feed=longpoll&heartbeat=10000&since=11-g1AAAACLe(...)AqSw&limit=50)

net::ERR_INCOMPLETE_CHUNKED_ENCODING

All other communication between the CouchDB/PouchDB instances is working out fine, I suspect the error occurs because of the longpolling.

See also 1.3.12. /db/_changes — Apache CouchDB® 3.2 Documentation.

Any pointers in the right direction appreciated. :wink:

Cheers

Ok, setting my Endpoint configuration like this prevents the error:

  http: [
    ip:  {0, 0, 0, 0},
    port: 4000,
    protocol_options: [
      idle_timeout: :infinity
    ]
  ]

But looking at Plug.Cowboy — Plug.Cowboy v2.5.2 and Nine Nines: ranch_tcp(3) it seems like setting…

  http: [
    ip:  {0, 0, 0, 0},
    port: 4000,
    keepalive: true
  ]

…should be the better solution, but has no effect. How do I pass the keepalive option to Cowboy from my config.exs?