JDBC Connection times out in deployed web app with hosting service - sql-server

I am using JDBC to create a connection to an MS SQL Server Database. The same code and connection string works fine on a number of platforms and in particular in my spring MVC Web Application.
After deploying the web application to a remote tomcat hosting service, everything appears to work fine in the code except that the database connection times out.
"com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host <IP Address>, port 1433 has failed. Error: "connect timed out. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall."
The hosting company says I must provide the exact steps to recreate the problem which may not be ideal. The only thing I can think of is to write another cut down application that connects to a different db with different credentials and test that in dev and deploy and then email them the war so they can deploy it and test it in their own environment.
Does anyone know of reasons why this might happen with a hosting service, like blocking the database response for some reason? Or is this very unlikely and should I assume that I am doing something wrong and persevere in understanding what might be different between my dev app and deployed app that could cause this timeout. Not that I can think of anything.
I don't want to take all that time if there is a common reason why this might happen that someone could point me to.
Thank you.

Related

.Net 6 App-Service won't connect to SQL in production

I have several sites hosted on the same App Service Plan - an S1 instance. All are using the same set out Outbound IPs. I have a SQL server VM where all the databases live. I have a network security group with an inbound rule for the S1's outbound IPs.
All my other sites work perfectly and have access to the SQL VM and their respective databases.
The site in question works perfectly when hosted from my local dev machine, WITH the production database.
Yet I get an Access Denied error: "SqlException: A network-related or instance-specific error occurred...] when I promote it to production on Azure.
All the usual suspects (firewall, user doesn't exist, etc.) can be ruled out because ALL my other sites are using the same database server, credentials, and the only change in the connection string is the Initial Catalog. They are all on the same App Server and all have the same outbound IP so if one was getting blocked the others would be also. If it were a user problem, it wouldn't work when hosted locally.
The only difference between this and my other web apps is that this one is Blazor, built on .Net 6. The others are on .Net Core 3.1 (LTS). I don't think that has any bearing since the application in question, when hosted locally works with the production connection string. This IS the first time I've published a Blazor app and .Net 6 app, so...
I'm sure I'm missing something silly, but I can't figure out why this one site would act differently than the rest.
Could someone please offer up another avenue for me to pursue? Or, a way to get a more verbose error message from the failed connection? Anything to further my troubleshooting?
For anyone reading this, I found my issue and it's unique to my project.
The truth, I separated the DAL from the presentation of the site. In the end, I was editing the wrong appsettings.json file. For three hours. Face-palm
My apologies if I wasted anyone's time.

How can I see all connection attempts with my GAE server?

I am running my application on GAE, for ex., http://example.appspot.com.
I think the standard log displays the details related to HTTP/HTTPS connections with my server. What if someone tries to connect with telnet? ftp? or any other way of connection? Or user connects with HTTPS, but with wrong certificate? Where could I see all such attempts?

Azure AWS Db Connection

I’m having a very specific issue with Azure and I couldn’t find any solution on the web.
So, we are little by little migrating our client’s infrastructure to Azure and we are starting with our Workers (webjobs).
These webjobs need to consume data present on a AWS SQL Server instance.
We already have checked that the App Service Plan’s Outbound IPs are whitelisted and that the SQL server is listening on TCP port 1433.
An evidence of that is the fact that we are able to communicate with the SQL Server instance through the Azure Debug Console:
But when we run the WebApp, the worker cannot find and connect to the same DB:
Does anyone have a clue of how I can solve this issue? It would be very appreciated!
Well, as you demonstrated by the first image, the SQL Server instance is configured correctly.
The worker Outbound IP address is definetely the same as the App Service Plan's machine.
Based on that, can you then please check if the Connection string you are setting have 'tcp:' before the IP Address?
Sometimes you need to force it, otherwise IIS can choose other ways to connect to your SQL server (like UDP for instance).

azure sql connectivity from local sql server

I am working with azure based application. In which, I need to get connected with azure sql server. I had already configured firewall setting on azure portal for my IP address. But still even when I tried to get connected to azure sql server, it never gets connect at the very first time. When I try to connect it more than two times then it gets connected.
This problem is also with application level connectivity, when i try to run the application on visual studio same happens.
I had researched a lot regarding this specific problem but didn't get any solution yet. I always get network related error Error Code : 53.
Any help will be appreciated.
This looks a lot like a local network issue.
When your application is deployed onto an Azure resource (App service, VM, etc.) does it get a similar connection error?
Every Azure SQL Server has a firewall, you need to create a client IP rule but also to allow access to the Azure service.

What services are required by SQL Express/SQL Server?

One of our partners recently reported that our software could not contact a remote instance of SQL Express until they started the RPC Locator and SQL Server Browser services. Where would I find a list of services that must be running, on both server and client, to enable remote access to SQL Express and/or SQL Server?
Sadly, the SQL Express documentation does not appear to include this detail.
SQL Express always installs as a named instance (servername\sqlexpress) and hence has a dynamic port assigned to it. The SQL Browser service is required for clients to locate the instance. Without the SQL browser, a client won't know what port the service is listening on.
Looking at my current installation of SQL Server, I have remote connections enabled and working and both RPC Locator and SQL Server Browser services are disabled on the machine.
The key is that you have to enable remote connections properly in the Surface Area Configuration Wizard.
I've experienced problems in the past running linked server queries if the MS DTC (Distributed Transaction Co-ordinator) service was not running
I don't know of any services that need to running on the client (unless they're application dependencies), but for the server, this KB article explains how to enable remote connections to SQL Server: http://support.microsoft.com/kb/914277.
By default, SQL Express is configured to only allow local connections. The gist of the article is: use the Surface Area Configuration tool to tell the SQL service to listen on tcp/ip and/or named pipes; then enable the SQL Browser service (or don't, and use a specific port in your client connection); and finally, poke a hole in your firewall. Anecdotally, I think most people have the most trouble with the firewall exceptions.
I think the RPC Locator service is more of a general windows service for handling COM calls, so I'm not sure it's fair to characterize it as a SQL-specific requirement; your app may require it to connect, but I don't know that every app would (e.g. Mitchel says that his installation works fine w/out it).

Resources