Azure connection drops constantly

Asked

Viewed 245 times

0

I’m using Visual Studio 2015, C# and database SQL Server Azure and developing a project Windows Forms.

Everything works perfectly, only when I spend a certain time without running my application to test, I get the error:

Instance-specific or network error when connecting to SQL Server. The server was not found or not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (Preview: Named Pipes Provider, error: 40 - Unable to open connection to SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): The network path was not found

error appears on line:

private void Form1_Load(object sender, EventArgs e)
{
    -> this.usuarioTableAdapter.Fill(this.estoqueDataSet.Usuario);
}

So I need to open the Server Explorer, click on my Data Connection and click on the refresh then it’s normal again.

I’m so new at Visual Studio how much in the Azure and I want to know if this is normal, if there is a risk of it happening when my client is using my program and if there is a way to "disable" this shutdown.

Follow my firewall configuration:

  • @Guilhermenascimento as I do to find this file?

  • is a windows Forms, not web

  • is true. And how is the connection configuration ("Data Source=????)?

  • Data Source=.database.windows.net;Initial Catalog=stock;Persist Security Info=True;User ID=;Password=***

  • Just set this in one place or another place with another variable that uses the same value? Just to be sure. Also checks if at the time the error occurs O caminho da rede não foi encontrado SQL Server service is still running.

  • Boy, I’m afraid I can’t tell you about the other variables. as for the SQL Server running it is, because the Azure service (as far as I know) is always online

  • found this here -> Data Source=.database.windows.net;Initial Catalog=stock;Integrated Security=False;User ID=;Password=*******;Connect Timeout=60;Encrypt=False;Trustservercertificate=True;Applicationintent=Readwrite;Multisubnetfailover=False

  • It could be anything, if you can give more details. Take a look at the firewall, or if you have an "Anti-ddos"

  • thanks so I’ll keep testing here. thanks anyway ^^

  • I’ll change the connect Timeout=60 to a larger number and see if it solves ;)

  • @Italorodrigo changing the Timeout is not the best way. We have to solve the cause of it. And not the responsible for treating the problem.

Show 6 more comments

1 answer

2


By using Azure Tools with Visual Studio, it will help you with several small tasks to speed up development.

Azure SQL by default does not accept connections from outside of Azure Data Centers in order to have this access, whether it is necessary to add the necessary Ips or range of Ips to the exception list of Azure SQL firewall.

From the symptoms you mentioned, it seems to me that Azure Tools is adding your IP to this list automatically and transparently. I believe that by going for a while without testing the app, your IP may change and exit the IP list, causing exactly the error you are receiving.

In the exception list, you can put a *, so the bank will be able to receive connection from anywhere. But I discourage to do, totally.

The best solution I see for your scenario is, between your Windows application and your Azure SQL database, put a Webapi interface.

See this post about how to create your first service Rest with Webapi. It is very simple and will help too much in the maintenance of your application.

And to communicate your Windows application with your Webapi service, I recommend using Fluent HTTP. Very simple, intuitive and elegant.

Finally, I recommend too much, instead of making your application with Winforms, to do it with UWP - Universal Windows Platform. Windows Forms is legacy technology and I strongly believe it will be completely out of the market in a few years.

  • my Azure firewall looks like this -> http://i66.tinypic.com/2ynmi6v.png. by logic, it should free up for everyone. there is some other way to do/configure this release (just as you spoke of the *)?

  • Thinking seriously about buying mysql hosting and making my program using it :/ , there is a lot of difference in winforms programming for uwp?

  • @Italorodrigo yes, there is a lot of difference in presentation. One uses XAML and one does not. But UWP and the future of Windows apps, and the same build runs on Windows PC, on Raspberrypi hardware, on Windows Mobile, on Xbox One, on tablets, etc.

  • @Italorodrigo only for return, I could not open the image.

  • see this link -> http://oi66.tinypic.com/2ynmi6v.jpg

  • Another thing: from what I saw UWP generates windows 10 applications and other platforms. then it will run in previous windows? and what about the database? currently I use Azure and I think to pass to Mysql, I will have how to use?

  • @Italorodrigo UWP eh for Windows 10 or later only. But this is already another discussion, so open another topic so we do not mix the subjects, can it be? Post here the link of the post that we continue there.

  • Hi Thiago, I already did some research on UWP and I thought it was really cool. at the moment I will complete this project in windows Forms because I will use on machines with old windows. I am grateful for your attention. hug.

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.