Databricks Apps Streaming issue

the_peterlandis
New Contributor III

I have .NextJS Databricks Apps with streaming enabled by setting "stream:true" in the JSON body which tells serve to return a streaming response (SSE format).  Now this works just fine when I run the app locally via npm run dev but once I deploy the app via Databricks Apps, streaming is not longer available.  It waits until the whole response is done and then displays the whole response all at once.  It appears that Databrics App has a proxy that is preventing streaming when stream:true is set.

the_peterlandis
New Contributor III

What resolved this issue is to set the following headers listed below.  

Content-Type: "text/event-stream"
Connection: "keep-alive"
Transfer-Encoding: "chunked"

These headers help prevent proxy interference:

  • Connection: "keep-alive" explicitly tells proxies not to close the connection, preventing premature termination
  • Transfer-Encoding: "chunked" signals the proxy that variable-length chunks are normal, not an error
  • Content-Type: "text/event-stream" hints to the proxy this is streaming data, deserving special handling

View solution in original post