EldoS | Feel safer!

Software components for data protection, secure storage and transfer

TElHTTPSClient.Get("localhost") always failed

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#37098
Posted: 06/23/2016 23:38:58
by shawn jun (Basic support level)
Joined: 04/12/2016
Posts: 9

We're using WindowsXP, .NET 3.5.
We have a local hosted webService which using Https Tls1.2, we've tested the service is running good by Internet Browser with url: https://localhost.
this is the code we're using:

Code
TElHTTPSClient HTTPSClient = new SBHTTPSClient.TElHTTPSClient();
HTTPSClient.Get("localhost");


it always popup an exception: System.Net.Sockets.SocketException: No such host is known
at System.Net.Dns.GetAddrInfo(String name)
at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
at System.Net.Dns.GetHostEntry(String hostNameOrAddress)
at SBSocket.__Global.ResolveHostName(String HostName, Boolean UseIPv6)
at SBSocket.TElDNSSettings.ResolveHostName(String HostName, Boolean UseIPv6)
at SBSocket.TElSocket.AsyncConnect(Int32 Timeout)
at SBSocket.TElSocket.Connect(Int32 Timeout)
at SBSimpleSSL.TElCustomSimpleSSLClient.Open()
at SBHTTPSClient.TElHTTPSClient.PerformRequest(Int32 Method, String URL)
at SBHTTPSClient.TElHTTPSClient.Get(String URL)
at HttpsWithTls.Program.Main(String[] args) in....

any idea?
#37099
Posted: 06/24/2016 02:39:20
by Eugene Mayevski (EldoS Corp.)

Thank you for the report, we will check it. On some systems localhost is not properly resolved, 127.0.0.1 should work instead. Also it makes sense to specify the protocol in the address, i.e. write "http://localhost" instead of just "localhost". Otherwise the parser might be unable to understand whether it's a domain name or a relative path.


Sincerely yours
Eugene Mayevski
#37111
Posted: 06/25/2016 16:39:56
by Eugene Mayevski (EldoS Corp.)

The parser understands "localhost" as a host name, so I guess the problem is that the system doesn't know that localhost is 127.0.0.1 . This does happen on some systems and it depends on how DNS is set up and on the records in \Windows\System32\drivers\etc\hosts file.


Sincerely yours
Eugene Mayevski
#37112
Posted: 06/25/2016 21:49:33
by shawn jun (Basic support level)
Joined: 04/12/2016
Posts: 9

Hi,
Just tried 'https://127.0.0.1', still got the same exception, while the url do works via Internet Browser.
#37116
Posted: 06/27/2016 12:52:02
by Ken Ivanov (EldoS Corp.)

Shawn,

Do I understand you right that your code looks like the one below and still gives you System.Net.Dns.GetAddrInfo(String name) at the top of the stack?

Code
    TElHTTPSClient HTTPSClient = new SBHTTPSClient.TElHTTPSClient();
    HTTPSClient.Get("https://127.0.0.1/");


Ken
#37122
Posted: 06/27/2016 21:25:30
by shawn jun (Basic support level)
Joined: 04/12/2016
Posts: 9

Code
          
SBUtils.Unit.SetLicenseKey("XXXXXXXXXX");
HTTPSClient.OnCertificateValidate += HTTPSClient_OnCertificateValidate;
HTTPSClient.OnData += HTTPSClientOnData;
HTTPSClient.Get("https://127.0.0.1/");


Exception:
Quote
Error in Main(...), detail: System.Net.Sockets.SocketException: No such host is known
at System.Net.Dns.GetAddrInfo(String name)
at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
at System.Net.Dns.GetHostEntry(String hostNameOrAddress)
at SBSocket.__Global.ResolveHostName(String HostName, Boolean UseIPv6)
at SBSocket.TElDNSSettings.ResolveHostName(String HostName, Boolean UseIPv6)
at SBSocket.TElSocket.AsyncConnect(Int32 Timeout)
at SBSocket.TElSocket.Connect(Int32 Timeout)
at SBSimpleSSL.TElCustomSimpleSSLClient.Open()
at SBHTTPSClient.TElHTTPSClient.PerformRequest(Int32 Method, String URL)
at SBHTTPSClient.TElHTTPSClient.Get(String URL)
at HttpsWithTls.Program.Main(String[] args) in c:\Work\adfadfadfsadfsd\Program.cs:line 20


My hosts file(only one line):
Quote
127.0.0.1 localhost
#37123
Posted: 06/28/2016 04:37:46
by Ken Ivanov (EldoS Corp.)

Thanks. Could you please let us know the following:

1) What is the nature of your application that consumes SBB? Is it a console app, a UI app, a service?

2) Do you get the same issue when connecting to public online services, such as https://www.google.com?

3) Could you please check the value of your TElHTTPSClient's UseIPv6 property, and if it's set to true, try switching it off?

Ken
#37128
Posted: 06/28/2016 21:32:58
by shawn jun (Basic support level)
Joined: 04/12/2016
Posts: 9

Quote
Ken Ivanov wrote:
Thanks. Could you please let us know the following:

1) What is the nature of your application that consumes SBB? Is it a console app, a UI app, a service?

2) Do you get the same issue when connecting to public online services, such as https://www.google.com?

3) Could you please check the value of your TElHTTPSClient's UseIPv6 property, and if it's set to true, try switching it off?

Ken

1) Console app.
2) No, the public domain is good to access via SBB.
3) The source code already pasted, I didn't touch this property.

I deployed this app to another machine which works good for domain name 'localhost'. question here is just to make sure we would not get in any trouble future.
#37133
Posted: 06/29/2016 04:30:23
by Ken Ivanov (EldoS Corp.)

Shawn,

Thank you for the details.

Could you run the following two commands from a console and check their output please:

Quote

1) nslookup localhost

2) ping localhost


Ken
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages

Reply

Statistics

Topic viewed 1322 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!