1
votes

I have a .NET WCF Service application that is running on an Azure Virtual Machine. It connects and interacts with a Azure SQL Database that has been whitelisted and all works correctly. After some amount of time (usually 5 to 7 days), the Azure Virtual Machine can no longer connect to the Azure SQL Database. Here is what I have checked when it is in this broken state:

1) I have turned off connection pooling and checked "netstat -a" to see if my app is leaking connection when it gets to this state. It is not.

2) I pointed my local development machine (running the same app) at the Azure SQL Database. Everything works fine. No issue connecting.

3) I have tried to telnet from the Azure Virtual machine to the Azure SQL Database on port 1433. It does not connect. After the reboot I mention below, I can telnet to 1433 just fine.

4) I have tried to telnet from my local development machine to the Azure SQL Database on port 1433. It connects fine.

So, it appears to be an issue with the Virtual machine finding the Azure SQL Database.

To get it working again, I have to reboot the virtual machine. iisreset or cycling the application pools have no effect.

This has happened 5 times in the last month. Once I reboot the Virtual Machine it will work fine for approximately 5 to 7 days and then gets into this state again. It does not seem to recover on its own, as I have left it in this state for over a day to see if it would self-correct.

Any help to either resolve the issue or ideas on what to check when it gets in this state would be very much appreciated.

2
Have you checked for memory leaks? SQL VM does not close any ports voluntarily so the fact that a port gets closed after few days points to a possibility of a memory leak causing the port to close.Shantanu
I have the exact same problem except I don't get any content from the azure db in my app, as if it's not connecting at all. But FreeTDS connected to the database just fine. I wonder it it's problem related to virtual machine itself or OS installed on it, because app works on my pc. If I solve the problem, I'll let you know how it was solved. :)DetectiveShmee

2 Answers

1
votes

Converting comment to answer :

Have you checked for memory leaks? SQL VM does not close any ports voluntarily so the fact that a port gets closed after few days points to a possibility of a memory leak causing the port to close.

0
votes

This was caused by a windows service that was leaking memory. When the service got to around 400MB of RAM consumption, then I was able to reproduce the block telnet to the DB server on 1433. When I recycled the service, it started to work. I have fixed the leak and everything is now working ok.