What does Net::HTTP use for name resolution?

35 views
Skip to first unread message

Walter Lee Davis

unread,
Oct 6, 2015, 8:36:35 AM10/6/15
to rubyonra...@googlegroups.com
I have the following in a controller method:

begin
response = Net::HTTP.post_form(URI.parse(File.join(@site.url, 'scan_folder.json')), {inlay_key: @site.key})
@response = JSON.parse(response.body.to_s)['remote']
@response_type = 'success'
@site.tested_client = true
@site.save
rescue
@response = 'Could not locate Inlay Client.'
@response_type = 'error'
end

And it seems to work very well. But I have a test site that it is not finding. When I comment out the rescue portion, the error I get indicates that the host could not be found. I have tried adding a line to the hosts file (the way you would on a Mac to do fake DNS for a development site) and this too appears to be ignored completely. The Rails server is running on Ubuntu 14, with all the latest patches, and I even tried rebooting the entire server to get any caches to clear. Dig on the server is able to find the test machine, but Net::HTTP on the same server cannot.

Can anyone offer a direction to start looking? Are there configurations that I could be doing to ensure that lookup is exhaustive before giving up?

Thanks,

Walter

Hassan Schroeder

unread,
Oct 6, 2015, 1:09:32 PM10/6/15
to rubyonrails-talk
On Tue, Oct 6, 2015 at 5:35 AM, Walter Lee Davis <wa...@wdstudio.com> wrote:

> And it seems to work very well. But I have a test site that it is not finding. When I comment out the rescue portion, the error I get indicates that the host could not be found. I have tried adding a line to the hosts file (the way you would on a Mac to do fake DNS for a development site) and this too appears to be ignored completely. The Rails server is running on Ubuntu 14, with all the latest patches, and I even tried rebooting the entire server to get any caches to clear. Dig on the server is able to find the test machine, but Net::HTTP on the same server cannot.

The (std) library name is Resolv, and no, it doesn't use /etc/hosts by
default, just the servers referenced in /etc/resolv.conf.

There is however a Resolv::Hosts that you could fall back to for
test purposes.

What's in the /etc/resolv.conf on your server?

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Consulting Availability : Silicon Valley or remote

Walter Lee Davis

unread,
Oct 6, 2015, 8:37:56 PM10/6/15
to rubyonra...@googlegroups.com

On Oct 6, 2015, at 1:08 PM, Hassan Schroeder <hassan.s...@gmail.com> wrote:

> On Tue, Oct 6, 2015 at 5:35 AM, Walter Lee Davis <wa...@wdstudio.com> wrote:
>
>> And it seems to work very well. But I have a test site that it is not finding. When I comment out the rescue portion, the error I get indicates that the host could not be found. I have tried adding a line to the hosts file (the way you would on a Mac to do fake DNS for a development site) and this too appears to be ignored completely. The Rails server is running on Ubuntu 14, with all the latest patches, and I even tried rebooting the entire server to get any caches to clear. Dig on the server is able to find the test machine, but Net::HTTP on the same server cannot.
>
> The (std) library name is Resolv, and no, it doesn't use /etc/hosts by
> default, just the servers referenced in /etc/resolv.conf.
>
> There is however a Resolv::Hosts that you could fall back to for
> test purposes.
>
> What's in the /etc/resolv.conf on your server?

Thanks for the tip. Here's the contents:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.4.4
nameserver 8.8.8.8
nameserver 209.244.0.3

I'm going to experiment with adding my EasyDNS hosts to this lookup list.

Walter

>
> --
> Hassan Schroeder ------------------------ hassan.s...@gmail.com
> http://about.me/hassanschroeder
> twitter: @hassan
> Consulting Availability : Silicon Valley or remote
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yDdmTAejbGjCQa9RGGPv-tx7P0pd1Kkt6kK%3DV1svMf0Bg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

Walter Lee Davis

unread,
Oct 6, 2015, 9:54:56 PM10/6/15
to rubyonra...@googlegroups.com

On Oct 6, 2015, at 8:37 PM, Walter Lee Davis <wa...@wdstudio.com> wrote:

>
> On Oct 6, 2015, at 1:08 PM, Hassan Schroeder <hassan.s...@gmail.com> wrote:
>
>> On Tue, Oct 6, 2015 at 5:35 AM, Walter Lee Davis <wa...@wdstudio.com> wrote:
>>
>>> And it seems to work very well. But I have a test site that it is not finding. When I comment out the rescue portion, the error I get indicates that the host could not be found. I have tried adding a line to the hosts file (the way you would on a Mac to do fake DNS for a development site) and this too appears to be ignored completely. The Rails server is running on Ubuntu 14, with all the latest patches, and I even tried rebooting the entire server to get any caches to clear. Dig on the server is able to find the test machine, but Net::HTTP on the same server cannot.
>>
>> The (std) library name is Resolv, and no, it doesn't use /etc/hosts by
>> default, just the servers referenced in /etc/resolv.conf.
>>
>> There is however a Resolv::Hosts that you could fall back to for
>> test purposes.
>>
>> What's in the /etc/resolv.conf on your server?
>
> Thanks for the tip. Here's the contents:
>
> # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
> # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
> nameserver 8.8.4.4
> nameserver 8.8.8.8
> nameserver 209.244.0.3
>
> I'm going to experiment with adding my EasyDNS hosts to this lookup list.

I tried, but failed to get the resolv.conf file to update to include my EasyDNS name servers. But for some reason, fiddling with this, and trying out Resolv directly in a Ruby test script seemed to jar something loose, and the previously hidden host is now being found by the Net::HTTP command, and all is just working. I hate when that happens, I wish there was something I could learn from this and apply again in future.

Walter

>
> Walter
>
>>
>> --
>> Hassan Schroeder ------------------------ hassan.s...@gmail.com
>> http://about.me/hassanschroeder
>> twitter: @hassan
>> Consulting Availability : Silicon Valley or remote
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
>> To post to this group, send email to rubyonra...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yDdmTAejbGjCQa9RGGPv-tx7P0pd1Kkt6kK%3DV1svMf0Bg%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/63273D34-6E26-4415-83F9-1D43C9ECD710%40wdstudio.com.
Reply all
Reply to author
Forward
0 new messages