Showing posts with label apparently. Show all posts
Showing posts with label apparently. Show all posts

Sunday, March 11, 2012

Bug in SQLDMO SQLServer.Connect if server is behind a firewall

Apparently the Connect method (as well as the PingSQLVersion method) of the
SQLServer object in the SQLDMO library does not honor any of the timeout
property values (BlockingTimeout, LoginTimeout, or QueryTimeout) if a remote
server is firewalled.
Apparently if the remote server is firewalled, the connection attempt will
always timeout after about 45 seconds.
What is interesting is the server responds and is added to the NameList
object when an Application.ListAvailableSQLServers method call is made. I
believe this works by sending a broadcast on UDP port 1434, correct? So why
would this respond even though the port is firewalled -- that's what I find
a
bit odd, or at the very least inconsistent.
Granted, if the server is local and it's firewalled, it will connect. I'm
guessing SQLServer.Connect has a few methods in which it tries to make the
connection.
I've been able to reproduce this in a consistent manner dozens of times. I
guess my question is whether or not there's a workaround or something else I
can do to prevent my application from waiting until that timeout limit is
reached.Hi
Are you sure the firewall does not have specific rules that allows you to
connect on the port rather than a blanket block?
John
"Rob Gomes" wrote:

> Apparently the Connect method (as well as the PingSQLVersion method) of th
e
> SQLServer object in the SQLDMO library does not honor any of the timeout
> property values (BlockingTimeout, LoginTimeout, or QueryTimeout) if a remo
te
> server is firewalled.
> Apparently if the remote server is firewalled, the connection attempt will
> always timeout after about 45 seconds.
> What is interesting is the server responds and is added to the NameList
> object when an Application.ListAvailableSQLServers method call is made. I
> believe this works by sending a broadcast on UDP port 1434, correct? So w
hy
> would this respond even though the port is firewalled -- that's what I fin
d a
> bit odd, or at the very least inconsistent.
> Granted, if the server is local and it's firewalled, it will connect. I'm
> guessing SQLServer.Connect has a few methods in which it tries to make the
> connection.
> I've been able to reproduce this in a consistent manner dozens of times.
I
> guess my question is whether or not there's a workaround or something else
I
> can do to prevent my application from waiting until that timeout limit is
> reached.|||Not sure. This is the firewall provided in Windows XP.
Moreover, what I'm more concerned with is the fact that when calling the
Connect() method, instead of failing immediately (or after the LoginTimeout
expires) it times out after 45 seconds -- despite what I define for the
timeout properties for the SQLServer or SQLServer2 object.
"John Bell" wrote:
> Hi
> Are you sure the firewall does not have specific rules that allows you to
> connect on the port rather than a blanket block?
> John
> "Rob Gomes" wrote:
>|||Only LoginTimeout has any effect on this behavior, BlockingTimeout and
QueryTimeout have no affect.
Which client protocols are enabled and what is the default protocol?
If I am forcing TCP it works on my machine as expected, when the firewall is
closed it returns after 15 seconds, using the following code sample
using System;
using System.Runtime.InteropServices;
using SQLDMO;
namespace SDN
{
/// <summary>
///
/// </summary>
class App
{
[MTAThread]
static void Main(string[] args)
{
try
{
SQLServer2Class s = new SQLServer2Class();
s.LoginSecure = true;
s.LoginTimeout = 15;
s.Connect("tcp:gertd00,1433", null, null);
s.DisConnect();
}
catch(System.Runtime.InteropServices.COMException ex)
{
Console.WriteLine(ex);
}
catch(System.Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
GertD@.SQLDev.Net
Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
Copyright SQLDev.Net 1991-2005 All rights reserved.
"Rob Gomes" <RobGomes@.discussions.microsoft.com> wrote in message
news:DD239C68-DC06-42B0-96B8-67DDEBB7EE90@.microsoft.com...
> Not sure. This is the firewall provided in Windows XP.
> Moreover, what I'm more concerned with is the fact that when calling the
> Connect() method, instead of failing immediately (or after the
> LoginTimeout
> expires) it times out after 45 seconds -- despite what I define for the
> timeout properties for the SQLServer or SQLServer2 object.
> "John Bell" wrote:
>