HTTP streamed / tagged responses to Heroku using clojure

I am creating a clojure web application that passes data to clients using chunked HTTP responses. This works fine when I run it locally using foreman , but does not work properly when I deploy it to Heroku.

A minimal example demonstrating this behavior can be found in my github here . The interface (in resources/index.html ) executes an AJAX GET request and prints pieces of the response as they arrive. The server uses an http-kit to send a new fragment to connected clients every second. By design, the HTTP request never completes.

When the same code is deployed to Heroku, the HTTP connection is closed by the server immediately after sending the first fragment. This seems to be the Heroku routing grid that causes this disconnect.

This can also be seen by running a GET request using curl:

 $ curl -v http://arcane-headland-2284.herokuapp.com/stream * About to connect() to arcane-headland-2284.herokuapp.com port 80 (#0) * Trying 54.243.166.168... * Adding handle: conn: 0x6c3be0 * Adding handle: send: 0 * Adding handle: recv: 0 * Curl_addHandleToPipeline: length: 1 * - Conn 0 (0x6c3be0) send_pipe: 1, recv_pipe: 0 * Connected to arcane-headland-2284.herokuapp.com (54.243.166.168) port 80 (#0) > GET /stream HTTP/1.1 > User-Agent: curl/7.31.0 > Host: arcane-headland-2284.herokuapp.com > Accept: */* > < HTTP/1.1 200 OK < Content-Type: text/html; charset=utf-8 < Date: Sat, 17 Aug 2013 16:57:24 GMT * Server http-kit is not blacklisted < Server: http-kit < transfer-encoding: chunked < Connection: keep-alive < * transfer closed with outstanding read data remaining * Closing connection 0 curl: (18) transfer closed with outstanding read data remaining The time is currently Sat Aug 17 16:57:24 UTC 2013 <-- this is the first chunk 

Can anyone guess why this is happening? It is assumed that HTTP streaming will be supported on the Kerok Geroku stack. The fact that the code works correctly with foreman indicates that it is something in the Heroku routing grid, causing it to break.

Live demo of a failed project: http://arcane-headland-2284.herokuapp.com/

+4
source share
2 answers

This is caused by an error in the http bundle , which will be fixed soon.

+1
source

https://devcenter.heroku.com/articles/request-timeout may mean: "long polls" like yours should send data every 55 seconds or stop.

0
source

Source: https://habr.com/ru/post/1497621/


All Articles