sparrell
Can I get Phoenix to not reply al all to certain http requests
For certain http requests, I would like to have no response. I know how to use send_resp return 500 or 404 or whatever, but is there a way to just disconnect with no response? ie I need a “send-no-resp”
Most Liked
voltone
If you want to close the TCP connection without sending a reply, and you can be sure the Plug adapter is Plug.Cowboy, then you could use this hack:
def no_reply(conn) do
{Plug.Cowboy.Conn, %{pid: ranch_pid}} = conn.adapter
Process.exit(ranch_pid, :kill)
end
Letting the connection time out without sending a TCP FIN while still clearing resources on the server would require low-level access to the kernel TCP stack. Not even the new socket module in OTP 22 can do that.
Edit: this works with Cowboy 1, probably not without changes on Cowboy 2, due to the changes in the process model
sparrell
The software is for command and control of security devices. There are two scenarios where it would be desirable for “no response”. One is if the device thinks the request came from a hacker instead of a valid authenticated authorized controller. I.e. don’t give the hacker any info at all - let them time out not knowing why. The other example is when responding at machine speed to a massive DDoS attack. The controller of the network under attack would prefer to fire & forget to billions of devices. If some percentage don’t work, they can be cleaned up later. It would still be preferably to hit more devices faster without worrying about the responses. The command language has an option to request this as part of the command. Although the real reason why it needs to be done is because the requirements say so
so I need to figure out how to do it.
NobbZ
I didn’t ask why you want to do so, but I asked if other software is involved that could do that.
Especially for the DDOS scenario, there are tools available that handle the connection drop at the kernel level and therefore could drop the connection faster than cowboy could even read the source IP.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









