How to create a keep-alive API endpoint with Cowboy in Elixir?

194 Views Asked by At

Note: I am new to elixir and the forum, and hence my question might be missing some details. Do let me know if additional information is required from my end. I am trying to integrate the trading view’s /streaming endpoint.

A snippet of what it says is: Stream of prices. Server constantly keeps the connection alive. If the connection is broken - the server constantly tries to restore it. TradingView establishes up to 4 simultaneous connections to this endpoint and expects to get the same data to all of them. Transfer mode is chunked encoding . The data feed should set 'Transfer-Encoding: chunked' and make sure that all intermediate proxies are set to use this mode. All messages are to be ended with \n . Data stream should contain real-time data only. It shouldn’t contain snapshots of data.

Can anyone help me implement an endpoint that can keep the connection alive? I am using cowboy as the framework.

I have already used Plug’s send_response and send_chunked in conjunction with halt, but it did not work out.

0

There are 0 best solutions below