Encountered a strange issue with Phoenix. I have a DELETE route in my router:
delete("/selections/:id", Selections, :delete_nitag_selections_id)
In my handler function, I perform business logic and return a 204:
TagSelection.Supervisor.delete_selections(namespace_id, [selection_id])
conn
|> send_resp(204, "No Content")
|> halt( )
The client successfully receives the response. It keeps the connection open, because it supports keepalive. But the very next request, whatever it is, either gets an error or connection closed prematurely.
I diagnosed that if I have the client send a “Connection: close” header WITH the DELETE request, such that Cowboy closes the connection after sending the response, subsequent responses succeed.
That’s weird. But here’s the really weird part. If I run it locally, in either dev or prod mode, with “iex -S mix phx.server” and have the client connect to it via HTTP, it always works. Requests after a DELETE always succeed.
However, I deploy my application to a container in Amazon ECS and route to it via the Amazon load balancer. In that configuration, all requests use HTTPS, and the failure described above occurs 100% of the time. Requests after a DELETE always fail unless I have the CLIENT send a “Connection: close” header with his DELETE request.
I’m stumped. Any thoughts?