Generate a new Elixir project using mix and add cowboy and plug as dependencies in mix.exs:
defp deps do
[
{:cowboy, "~> 1.0.0"},
{:plug, "~> 0.8.1"}
]
endThen add the sse.ex file below to lib/ and run the code with mix run --no-halt lib/sse.ex. Point your browser to http://localhost:4000 and you're done.
If you don't feel like writing your own EventSource JavaScript, you can use the example in index.html below that comes from Cowboy. Just create a priv/static directory inside of your project.
Oh, holding open WS connections is very expensive. Also, the SSE limit of 6 only applies to HTTP/1 connections and assuming you aren't using a CDN to route your SSE.