benonymus

benonymus

:inet.gethostbyname(Kernel.to_charlist(parsed.host)) url checking seems to be failing ?randomly? in tests

Hey I am using

:inet.gethostbyname(Kernel.to_charlist(parsed.host))

as part of my checking for valid urls, and it seems to be failing randomly in some tests, sometimes all the tests pass, sometimes 1-2 fail and the error is coming from here.
I am using google.com as the url, but i tried with other ones and it tends to happen with most.
To be even more exact the tests fail because the fixtures can’t be inserted while in the other 250+ cases it can
Any thoughts why can this happen?

Marked As Solved

NobbZ

NobbZ

Then for some reason DNS was unable to resolve the hostname. This is not related to the BEAM, but to the upstream DNS server.

Also Liked

NobbZ

NobbZ

What do you mean by “fail”? If by failing you mean the returned value does not match {:ok, _}, please tell us what it is instead. It might help to resolve the issue.

dimitarvp

dimitarvp

Sure, agreed. I didn’t address most of my comment towards you, sorry. Just now noticed I pressed the wrong button. :slight_smile:

I was just pointing out that the OP is trying to solve the wrong problem, in my opinion.

benonymus

benonymus

hey, thanks for all the responses, i did not know that i can or should adjust the behavior of my validation in case it is being run in test env.
if that is the case, how would one go about that? I am using it in a changeset function to validate url input from users.
On the same note, if I am not running it in test mode, how do i know for sure that it works in a way that i’d expect?
Also what i am most surprised by, is that it runs perfectly most of the time like 99.8%. My other idea was that it might have to do with not having the most stellar internet, since it only seems to happen when I am running the tests locally, in the deployment pipeline it hasn’t failed yet :crossed_fingers: . As for changing my dns, I am using that dns on router level, and I haven’t seen the tests fail since.

Where Next?

Popular in Questions Top

chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New

We're in Beta

About us Mission Statement