TIdTCPClient fails to resolve hostname multiple when not via primary DNS - delphi

Using Delphi XE 10.2.3 and Indy 10.6.2.
I have an application in which I use a TIdTCPClient, on a customer project we expirence some troubles using DNS name of the remote server.
It appears as the TIdTCPClient only uses the default dns for the lookup, however at this customer the DNS server which "holds" the DNS name to resolve is on the third DNS on the network adapter.
When,
Using nslookup hostname(URL) it fails
Using nslookup hostname(URL) dnsserver it works
Pinging works whithout problem.
So I guess that nslookup also only uses the primary DNS server, and maybe uses the secondary DNS if the primary (and so fourth) DNS server is unavailable.
Is there some property in the TIdTCPClient I can set, to make it iterate and use all DNS specified on the server or do I need a different approach to resolve the hostname and connect the TIdTCPClient?
I really don't want to put the name in the "hosts" file.
Error from TIdTCPClient connect and status event.
07:22:50 LARGE: ivDispatch status:Resolving hostname interviewalarmreceiver.corp.novocorp.net
07:22:50 ERROR: SendLowLevelPackage(-310070) Socket Error # 11001
Host not found.

Related

Connect ASP.NET Core container to remote SQL Server

I am trying to connect my ASP.NET Core application to a remote SQL Server.
The application is deployed using IIS WScore 2016 image. When I run the application on my host, it's working, but in the container using this connection string :
Data Source=xx.xxx.xx.xx,1433;Initial Catalog=somedb;User Id=xxxxxx;Password=xxxxx;
or:
Server=xx.xx.xx.xx,PORT_NB;Database=DATABASE;User Id=USER;Password=PASSWORD
But no luck - I am using the default Docker network.
The error is like this:
Error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - No such host is known.)
Notes:
The server is allowing the remote connection
All the connection strings are tested and can connect to the remote SQL Server from the application that runs on the host
I have read the Docker documentation and they mentioned the IP forwarding but the example was on linux containers and I did not find any help about connecting the Windows containers to a remote SQL Server
Question
My concrete question is how to expose the container to the outside world and I can connection my container to the other remote services like a remote SQL Server?
Should I use host network or bridge with the IP forwarding?
Any help? Thanks
I changed the connection string to this :
"ConnectionString": "Server=xx.xxx.xx.xx\\MSSQLSERVER,1433;Initial Catalog=Dbname;User Id=username;Password=xxxxxxx;"
then i restarted the AppPoll and it worked
What is the current network you're using for this container? If you used the default network, then you're using Network Address Translation (NAT). What that means is that you're using the host IP address to connect to the external network. So, your problem most likely is that the SQL Server is rejecting the connection from the IP of the container host.
The alternative on Windows is to use a different network drive. There are many options and I'd recommend you look at the option that better suits your needs: https://cda.ms/4nP
I had the same error, try removing the port from the connection string as follows:
"ConnectionString": "Server=ContainerName;Initial Catalog=Dbname;User Id=username;Password=xxxxxxx;"

Port forwarding, DMZ, turning off firewall and adding port doesn't work to reach out port

I am using Windows 10 with IIS 10.0
I am publishing website on IIS and I need to reach it with public ip.
What I did;
* Port forwarding through router
* Adding DMZ with my local IP
* Turning off firewall
* Adding port to firewall inbound rules with allow edge traversal
I can connect with internal IP like 192.168.1.75:81
I get "System.Net.Sockets.SocketException A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond from [MYPUBLICIP]" when I try to reach it like MYPUBLICIP:81
What are the possible scenarios that blocks to port?
Thanks.
As far as I know, the error message means there is no server listening at specified ip/port that you are trying to connect to.
In my opinion, you should firstly make sure your client machine could access your server by using this MYPUBLICIP address.
Then I suggest you could try to make sure the port 81 is your IIS web application port.
Besides, I suggest you could try to open your event viewer to find out the details error message.

Docker and EF Core: No connection could be made because the target machine actively refused it

I try to connect to the host's SQL Server Instance (SQL 2017 on Windows 10) from a Docker container (running a .NET Core app with EF Core).
The SQL Server is configured to listen on the default port 1433 (no dynamic ports are used) and to allow remote connections (TCP/IP). I also set up an inbound rule for the firewall and the given port (I also tried with firewall off). I can connect to the database and run SQL queries with the sqlcmd command line tool running in a Docker container.
This is the connection string I'm using:
Server=tcp:host.docker.internal,1433;Database=AuthIdentity;Trusted_Connection=False;User Id=sa;Password=xxxx;MultipleActiveResultSets=True;
When I run my container I get the following error:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: TCP
Provider, error: 0 - No connection could be made because the target
machine actively refused it.)
When I turn off my firewall (even if there is a firewall rule for the SQL port) I'll end up getting:
SqlException: A network-related or instance-specific error occurred
while establishing a connection to SQL Server. The server was not
found or was not accessible. Verify that the instance name is correct
and that SQL Server is configured to allow remote connections.
(provider: TCP Provider, error: 0 - A connection attempt failed
because the connected party did not properly respond after a period of
time, or established connection failed because connected host has
failed to respond.)
When I start the same program as IIS application (without any other changes) it's running perfectly fine and it's connecting as expected.
The error occurs when the program executes the first SQL operations (in this case it's the database migration - this is within the program startup)
serviceScope.ServiceProvider.GetRequiredService<ApplicationDbContext>().Database.Migrate();
EDIT: A simpler setup in another API project (both will raise the same errors as described above):
[HttpGet("setup")]
[AllowAnonymous]
public IActionResult Setup()
{
try
{
this._context.Database.Migrate();
return Ok("success");
}
catch (Exception e)
{
return Json(e);
}
}
[HttpGet("get")]
[AllowAnonymous]
public List<ApplicationUser> Get()
{
return this._context.Users.ToList();
}
EDIT 2: As suggested from #Mohsin Mehmood I run a test with the NAT address (from ipconfig /all) and I can successfully connect with the given IP (172.28.112.1) to the SQL server. I also checked what I receive when running docker run --rm -i microsoft/nanoserver:1709 ping host.docker.internal and it gets me 62.138.239.45 as the address.
Never the less I would appreciate a solution which is not using a "hard-coded" IP address but a DNS like host.docker.internal. I'm also not sure why both IP addresses are different (172.28.112.1 vs. 62.138.239.45) and why the container can't get the correct address from the DNS.
What are the things I'm missing? How can this problem be solved? I already searched Google and SO without any working answer.
I suggest to try Windows 10 host server IP address instead of domain host.docker.internal to confirm that issue is related to DNS resolution. Also, I found that there is still an open issue related to internal host dns resolution in windows containers

Remote connection to Neo4j server

I believe the way to creating a remote connection is by changing this line in conf/neo4j-server.properties, specifically by removing the comment and restarting the server.
org.neo4j.server.webserver.address=0.0.0.0
My URL is https://0.0.0.0:7473/browser/ and works on the local machine, but when I test the URL in Safari on iPhone over 3G, it cannot connect.
What do I set the address to in the properties file?
I thought it was the IP address of my computer, but after trying the remote address which I got from Googling “ip address mac” that didn’t work, nor did (obviously) the local IP address of my machine, 192.168.0.14
I should point out that setting it to the IP address from Google throws an error and the log reads:
2015-01-29 17:10:08.888+0000 INFO [API] Failed to start Neo Server on port [7474], reason [MultiException[java.net.BindException: Can't assign requested address, java.net.BindException: Can't assign requested address]]
With default configuration Neo4j only accepts local connections
In neo4j-community-3.1.0 edit conf/neo4j.conf file and uncomment the following to accept non-local connections
dbms.connectors.default_listen_address=0.0.0.0
By setting
org.neo4j.server.webserver.address=0.0.0.0
enables Neo4j on all network interfaces.
The remainder of that reply is not Neo4j related at all - it's regular networking. Double check if port 7473 (and/or 7474) are not blocked neither be a locally running firewall nor by your router. You local IP 192.168.0.14 indicates you're behind a router doing NAT. Therefore you have to setup a port forwarding in your router for the ports mentioned above.
Please be aware that this is potentially dangerous since everyone knowing your external IP can access your Neo4j instance. Consider using either https://github.com/neo4j-contrib/authentication-extension or use a VPN in favour of port forwarding.
in 3.0:
##### To have HTTP accept non-local connections, uncomment this line
dbms.connector.http.address=0.0.0.0:7474
Confused myself with the setting. Anyone who has the same problem, 0.0.0.0 just means “this server isn’t local any more” and so to access it you use the public IP address of the computer that’s hosting the Neo4j server.
Just make sure that the ports you set in the server properties (default are 7474 and 7473) are open for incoming connections on your router/firewall etc.
I think there's some confusion here. That configuration property org.neo4j.server.webserver.address is about which IP address the server you're starting listens on for external connections. Relevant documentation is here.
It seems you're asking how to configure your database to talk to a remote database. I don't think you can do that. Rather, by editing that file you're planning on running a database on the host where that file is. Your local database on that host will write files to wherever the org.neo4j.server.database.location configuration parameter points.
A remote connection is something that the neo4j shell might establish, or that you browser might make to a foreign server running neo4j; but you don't establish that sort of remote connection by editing that file. Hopefully this helps.
Also if you have ssh access to remote server with neo4j you can setup ssh tunnel to access it via localhost:
ssh -NfL localhost:7474:localhost:7474 -L localhost:7687:localhost:7687 yourname#yourhost
then type in browser:
localhost:7474
Depends on the version.
Look for the phrase 'non-local connections' in the conf file.(In my case, $NEO4J_HOME/conf/neo4j.conf)
Then follow the instructions in the comments.
In my case,
# With default configuration Neo4j only accepts local connections.
# To accept non-local connections, uncomment this line:
server.default_listen_address=0.0.0.0

Heroku sporadically returns "hostname" not found

I'm creating an iOS app that uses a Rails API backend on Heroku. Periodically (one every 20 API calls), heroku cannot be found. The following NSError is returned:
Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo=0x755ce00 {NSErrorFailingURLStringKey=https://xxx.herokuapp.com/api/v1/matchups, NSErrorFailingURLKey=https://xxx.herokuapp.com/api/v1/matchups, NSLocalizedDescription=A server with the specified hostname could not be found., NSUnderlyingError=0x71ca730 "A server with the specified hostname could not be found."
Seems like a DNS issue on the network to which your iPhone/iPad is connected. To be sure, try any of the following:
1) Change your host name to an IP address instead of a string hostname, and add a Host: header to the HTTP request.
2) If (1) is hard, set your iPhone's DNS to a PC on your LAN, and install a DNS server on that PC, and serve at least that specific address directly from the PC (don't recurse for that domain).
It looks like you are being hit by a Dyno sleep behaviour. Please check this documentation, specially the section Dyno sleeping and make sure you understand it.
Also there are several ways to keep the app on, like pinging the site regularly.
Another option is DNS, create an Ad-Hoc network on your computer and connect your iphone to that network. Use wireshark to make a network capture and analyse the DNS and HTTP responses.
Your url = https://xxx.herokuapp.com/api/v1/matchups
Did you explicitly specify your subdomain xxx with your domain provider to direct to your server IP?
If not, try add a new A record with your subdomain xxx point to your server IP.
Hope that helps.

Resources