Solved

Connecting to SQL server behind firewall advice

Posted on 2013-06-01
3
266 Views
Last Modified: 2013-06-01
I have an app that I have written that uses a SQL server that is behind a firewall. Each user has to launch iexpolorer then click a web link that lists all our firewalls before launching my app.

The problem is that it takes 60 seconds or more for either the firewall or SQL server to timeout in my app (not sure which). After which I pop a messagebox with a link to the webpage with the firewall links. Users are impatient because my app gives the appearance that nothing is going on.

I need some way to check the firewall state as soon as my app opens.

I thought what about internet history, I could check that when my app opens. I found some code that gets the history which I search for the firewall link.

But is there a way to check if the user connected to the firewall today? is there a date associated with the history.

MW
0
Comment
Question by:WINN2012
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 25

Expert Comment

by:clockwatcher
ID: 39213341
I would suggest having your client try to ping your server before you connect:

    Sub Main()
        If My.Computer.Network.Ping("YOUR_SQLSERVER") Then
            ' Continue with your program
        Else
            MessageBox.Show('Please connect to the firewall first')
        End If

    End Sub

Open in new window

0
 

Author Comment

by:WINN2012
ID: 39213389
I had tried that, its strange that I can ping the server without connecting to the firewall. I can get to the DB until I connect the firewall.

MW
0
 
LVL 25

Accepted Solution

by:
clockwatcher earned 500 total points
ID: 39213489
If you're using TCP/IP as your client protocol rather than something like named pipes, you can "ping the port" that sql server is running on.  Basically, try to set up a connection (with a timeout) on the port that your sql server is listening on,  if you can connect before the timeout  then you should be good to go.  If you can't then direct them to your firewall page.

    Sub Main()
        Dim client as new TcpClient()
        Dim result as IAsyncResult

        Dim server as String = "YOUR_SQLSERVER"
        Dim port as Integer = 1433 'default port that sql server listens on
        Dim timeout as Integer = 3000 'timeout in milliseconds
        Dim connected as Boolean = False

        result = client.BeginConnect(server, port, Nothing, Nothing)
        Dim wh as System.Threading.WaitHandle = result.AsyncWaitHandle
        if wh.WaitOne(timeout, False) then
            if client.Connected then
                connected = True
                client.close()
                ' continue your program
            end if
        end if
        client.close()
        if not connected then 
            MessageBox.Show("Connect to the firewall")
        end if 

    End Sub

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How can I add google maps in vb.net. 2 48
Web page design problem 3 42
How to embed a manual into my vb 2005 project 7 26
I need to clear List Box in MVVM panel. 15 27
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question