This is a very simple module that keeps checking the requester's IP. I use backconnect proxies which means that it gets new IP on every http request.
defmodule Test do
def go() do
Enum.each(1..1, fn x ->
Task.Supervisor.async_nolink(Scraper.TaskSupervisor, fn ->
r = HTTPoison.get("https://api.ipify.org?format=json", [],
[timeout: 10_000, recv_timeout: 10_000, proxy: "ip:port", ssl: [{:versions, [:'tlsv1.2']}]])
case r do
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
IO.inspect body |> Jason.decode
:timer.sleep(1000)
go()
end
end)
end)
end
end
Test.go()
:timer.sleep(2000000)
Problem? HTTPoison(hackney) doesn't release the connection as long as process is alive so IP is always the same. How would I manually close the connection inside:
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
IO.inspect body |> Jason.decode