I've been testing a website in Azure for about a month (Free trial), and now I've subscribed to pay-as-you-go. When I was on the free trial, I had absolutely no connectivity issues. Now I've deployed again to a fresh website created on the pay-as-you-go subscription with the same settings (scaling mode etc.) as the previous one. However, now when I navigate to my site, it sometimes fails to connect to my database:
Server Error in '/' Application.
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
Description: An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and where
it originated in the code.
Exception Details: System.ComponentModel.Win32Exception: 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
Source Error:
An unhandled exception was generated during the execution of the current web request.
Information regarding the origin and location of the exception can be identified using
the exception stack trace below.
Stack Trace:
[Win32Exception (0x80004005): 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]
[SqlException (0x80131904): 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.)
I try to refresh the page and it connects. After a few minutes, when I try again, I sometimes get the same error again, but sometimes not. I never had a single connectivity issue in the free trial mode. Why does it happend and how can I prevent this problem?
Transient errors are expected in a cloud environment. Let's say that a database call fails, if you retry a few milliseconds later, that same call would now work. To shield you from these errors, you need to implement a retry logic. If you use Entity Framework 6, you're in luck since it's baked in: http://msdn.microsoft.com/en-US/data/dn456835 Here's a quick video on how to implement this: http://www.azurerocks.com/0_oaw-merMw
You can also use the Enterprise Library Transient Fault Handling Application Block: http://msdn.microsoft.com/en-us/library/hh680934(v=pandp.50).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With