I am trying to connect to an sql server from my windows container. It all works fine when I spin up the container locally on my machine, or on an azure vm, and I can connect to the azure sql server but the connection fails when I deploy the container to azure container instance. The sql server firewall is open 0.0.0.0 to 255.255.255.255.
I believe that I have narrowed it down to a DNS issue because when I try to lookup the sql server or any host for that matter I get a "No such host is known".
There is a known 30 second startup delay but it still does not resolve after multiple retries.
IPHostEntry ipHostInfo = Dns.GetHostEntry("mysqlserver.database.windows.net");
IPAddress ipAddress = ipHostInfo.AddressList[0];
Console.WriteLine($"Ipaddress {ipAddress.MapToIPv4()}");
Further to my original question I have come up with two options to resolve this issue.
If you are working with a .netcore project then set build target to linux and deploy to a linux container/environment. The DNS lookup then works as it should.
If you are stuck with a non .netcore project then run a powershell script on the container bootstrap to force the container to use a public DNS such as Google (8.8.8.8).
$nic = Get-NetAdapter
Set-DnsClientServerAddress -InterfaceIndex $nic.IfIndex -ServerAddresses ('8.8.8.8')
Related
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;"
I am trying to run the infinispan docker image on a Windows 10 machine with docker desktop for windows.
I wrote a small test Java program that connects to localhost:11222 using hotrod and accesses a cache.
The problem is that after the initial connect the client receives from the server a new address 172.17.0.3:11222 and it fails connecting to this address because this is a docker internal one and
docker desktop for windows cannot route messages directly to an internal container address.
Is there any workaround available in infinispan or on the windows machine ?
The simplest solution is to disable the handling of topology updates in your Hot Rod client:
infinispan.client.hotrod.client_intelligence=BASIC
More information about client intelligence here.
Note that this is not recommended in production: the client will ignore new servers coming up and it will keep trying to contact the servers in the initial server list long after they stop.
I have a MVC application which is using Azure SQL database for data storage. I have created a docker image for the same.
Later, I have setup Kubernetes cluster on Ubuntu 18.4 using Kubeadm. The Linux VM is is created on azure cloud.
Initially, i have deployed my app on the single node cluster and the application was working as expected without any SQL connection issue. Then I have created two VM on the cloud and used it as Node 1 (master) and Node 2. Now i am facing an SQL connection issue after deploying my app on Node 2 machine.
Unhandled Exception: System.Data.SqlClient.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: 35 - An internal exception was caught) ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: Resource temporarily unavailable
I tried and verified below options-
Added IPs to Azure SQL database firewall settings
From Linux Machine, tried to connect SQL database using sqlcmd
POD network is install correctly (calico)
Tried adding outbound rule for SQL port 1433 on VM
I have created a SQL database on VM and tried to connect this database from MVC app and it is also working.
Can someone please help me to diagnose and fix this issue? Please let me know if you want more details on this.
On my Windows 10 host machine I am able to connect to a private SQL Server RDS instance running in AWS. However, a Docker container running locally on the same machine is unable to connect with the same connection string.
From the Docker container I am able to telnet to the server on 1433 successfully. However, when I connect from code, it seems to be unable to create a connection. No exception is thrown, but this code hangs:
using (var conn = new SqlConnection(connectionString)){
// Do something
}
I am able to successfully connect to SQL Server when it is running on a EC2 instance. It appears to be specific to RDS.
Fails with both the name and IP address.
This was caused by a bug in SQLClient as described on GitHub. There were two fixes that worked:
Downgrade the project from Net Core 3.1 to 2.2
Update Docker file to use aspnet:3.1-bionic instead of aspnet:3.1-buster-slim and sdk:3.1-bionic instead of sdk:3.1-buster
I'm trying to create a Test automation Pipeline to run my selenium scripts, I installed Jenkins in windows Remote Server 2012. Used following cmd($ java -jar jenkins.war) to start jenkins. It is working fine in Remote server with url:http://localhost:8080/
But when I'm trying to access it outside Remote server(my local machine) it is not working. am getting error message "This site can’t be reached"
My local laptop and Remote server is under the same proxy org network.
Can someone help how to resolve this issue , so that other folks can access it and run jobs when required from their laptops
Thanks in advance
Access Windows Firewall.
Add an inbound rule to allow port 8080 and
try accessing the url from any machine in the network.
you could allow/restrict access to all IPs, range of IPs or allow all. But to nullify the issue and confirm if its an issue with whitelisting IPs, I'd first allow access from all IPs with the wildcard *
for Debugging if its a port whitelisting issue, you could also telnet from the machine that you are trying to access this machine -
try
telnet remote machines IP Port
note: do not use a colon for port input just use a space