= Hackney (via HTTPost) request not returning result when running. =

Hi, I have a simple chat bot written in elixir. One of my usecase is to send some query to a particular url. I expected the query server to response a bit slow (few seconds). I've written my code and in my machine connection the query code is running normally. But when I deployed my application to a VPS, the query just don't return a response, not an error or any message

This kinda drives me mad since I don't have any way to debug it since the call itself seems to be stuck and doesn't return indefinitely. Running curl manually in the container does work, running the request inside iex that remotes the running node does work, but in the live system it doesn't work. Anybody could help me maybe? Below is the snippet of the code in question:
http_config = [ hackney: [pool: :tl], recv_timeout: 30_000, timeout: 30_000 ] with {:ok, body} <- jason.encodesrc"> query {:ok, %HTTPoison.Response{body: body}} <- body,http_config), httpoison.post(url, result" {:ok,> result, "src_lang" => src_lang}} <- do end jason.decode(body) result |> IO.inspect(label: :result)
Edit: I added the representing inspect line. Sometimes this snippet does run normally sometimes it doesn't. When I hosted this program in my friend's black friday dirt cheap dedicated VPS it never had this problem. But when I moved to Vultr is has this problem. I've also tried on another VPS provider I used in the past (ramnode) and have the same problem

First thing that jumps out at me is that your with statement has no else clause so you will not catch where it is failing

Try adding an else and pattern match on the
{:error, reason} tuple and the write it to log with sth like `Logger.error("Failed http post: #{inspect error
You should then be able to see why it is failing

p.s. it probably works on a remote shell on your local system due to the network call being done on the local machine (running the remoting node) rather than on the deploy server. To ensure the network call is happening on the remote server, spawn a process on the remote node (Node.spawn, e.g.) that makes the http call


Ah I'm sorry the snippet doesn't tell the whole story, but after that, no matter what happens I have a logger line which tells that the command has finished running, and in the end if the result is {:error, _} I log it. But in my case the line that tells the function has finished running never get call, it just like the post request just stuck waiting hand never returned

I use releases, and I run the release binary remote on the deploy server to connect to the current node running.