Code Monkey home page Code Monkey logo

Comments (4)

afair avatar afair commented on June 26, 2024

This is working properly for me now. It sounds like your DNS wasn't properly responding, which would explain the long time for response and and the returned errors.

It could also have been a DNS issue at google not returning the correct information. While I have not heard of a recent Google outage, the recent Facebook outage left clients repeatedly hitting public DNS servers like Google's 4.4.4.4 and 8.8.8.8, causing them to suffer service degradation.

Is this still happening? Are you using the most recent version?

We want to use DNS to validate domains as a step to ensure a valid email address, but if you give the host_validation: :syntax option, it will skip it, as you tried.

There is a configuration dns_timeout which takes the number of seconds to timeout. Currently, this is not set by the library, but perhaps should be. (See Resolv::DNS.timeout=)

from email_address.

KarlBishop avatar KarlBishop commented on June 26, 2024

It's still happening on my end today using 0.2.0 and after updating to 0.2.1.

One thing I forgot to mention: it's not consistent. Sometimes validating a Google managed address succeeds; sometimes it fails on the first attempt; sometimes on the second attempt; sometimes on the 8th attempt etc.

I saw dns_timeout is included in EmailAddress::Config.all_settings
But when I try running:

EmailAddress::Config.setting(:dns_timeout, 5000)
EmailAddress.valid?('[email protected]')

or

EmailAddress.valid?('[email protected]', dns_timeout: 5000)

...it does not reduce the time to fail. Do I need to set it via a different method (using Resolv::DNS)?

from email_address.

afair avatar afair commented on June 26, 2024

The timeout value is in seconds, so try something like 5 instead.

As far as the the inconsistency of validations, it sounds like your DNS service, otherwise other people would be raising this issue as well. Can you change your DNS to use Google (https://developers.google.com/speed/public-dns/docs/using) or Cloudflare (https://beebom.com/how-switch-to-cloudflares-1-1-1-1-dns/) and see if it solves your issue?

from email_address.

KarlBishop avatar KarlBishop commented on June 26, 2024

Thanks for correcting me on the timeout value - I'm too used to using milliseconds in Javascript!

And for the info on how to change DNS service.

In the end I have just worked around the issue by skipping the DNS check in development:

EmailAddress.valid?(params[:email], Rails.env.development? ? {host_validation: :syntax} : {})

from email_address.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.