G
Guest
The following illustrates a problem I have in another program ... however it
only occurs on one in 5,000 remote machines. I suspect the cause of the
problem lies with the remote machine ... but why doesn't my client time out
with an exception ?
The Get() method that initialises the asynchronous operation blocks for way
too long (I've not seen it give up).
Most of the time one will get an error of some sort, RPC not available,
Access Denied, COM is stuffed, etc ... but when it hangs it's gone ... and
it's repeatable against the machine ... but you have to find the right
machine.
Needless to say I've got a hugely multithreaded scanner trying to do all
this scanning for real ... but when one of the remote machines block this
initialisation ... then I'm stuffed.
I've unsatisfactorily tried to set up another thread to maintain a timeout
and abort the thread if it hangs too long during this method.
Note this method doesn't retrieve the data ... merely set's up the operation
.... so I believe.
I've not verified that the problem occurs in synchronous mode ... but
wbemtest.exe does have the same issue ... which isn't a .Net app ... so I
suspect this is a COM or WMI server issue.
Can anyone shed any light ?
class Console
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
System.Management.ManagementPath lWMIPath = null ;
System.Management.ManagementScope lWMIScope = null ;
System.Management.ObjectQuery lWMIWQL = null ;
System.Management.ManagementOperationObserver lWMIObserver =
null ;
lWMIPath = new System.Management.ManagementPath(
"\\\\remote-machine\\root\\cimv2" ) ;
lWMIScope = new System.Management.ManagementScope() ;
lWMIScope.Path = lWMIPath ;
lWMIScope.Options.Timeout = new System.TimeSpan( 0, 0, 0, 30 ) ;
lWMIObserver = new
System.Management.ManagementOperationObserver() ;
lWMIObserver.ObjectReady += new
System.Management.ObjectReadyEventHandler( ObjectReady ) ;
lWMIObserver.Completed += new
System.Management.CompletedEventHandler( Completed ) ;
lWMIWQL = new System.Management.ObjectQuery();
lWMIScope.Options.Authentication =
System.Management.AuthenticationLevel.Connect ;
using( System.Management.ManagementObjectSearcher lWMISearcher =
new System.Management.ManagementObjectSearcher( lWMIScope, lWMIWQL ) )
{
lWMISearcher.Query.QueryLanguage = "WQL" ;
lWMISearcher.Query.QueryString = "SELECT Name from
Win32_ComputerSystem" ;
lWMISearcher.Options.ReturnImmediately = true ;
lWMISearcher.Options.Timeout = new System.TimeSpan( 0,0,0,4 ) ;
lWMISearcher.Get( lWMIObserver ) ; // this line hangs forever ...
}
}
internal static void ObjectReady( object aSender,
System.Management.ObjectReadyEventArgs aArgs )
{
}
internal static void Completed( object aSender,
System.Management.CompletedEventArgs aArgs )
{
}
}
Using v1.1 .Net on 2k3 Server
only occurs on one in 5,000 remote machines. I suspect the cause of the
problem lies with the remote machine ... but why doesn't my client time out
with an exception ?
The Get() method that initialises the asynchronous operation blocks for way
too long (I've not seen it give up).
Most of the time one will get an error of some sort, RPC not available,
Access Denied, COM is stuffed, etc ... but when it hangs it's gone ... and
it's repeatable against the machine ... but you have to find the right
machine.
Needless to say I've got a hugely multithreaded scanner trying to do all
this scanning for real ... but when one of the remote machines block this
initialisation ... then I'm stuffed.
I've unsatisfactorily tried to set up another thread to maintain a timeout
and abort the thread if it hangs too long during this method.
Note this method doesn't retrieve the data ... merely set's up the operation
.... so I believe.
I've not verified that the problem occurs in synchronous mode ... but
wbemtest.exe does have the same issue ... which isn't a .Net app ... so I
suspect this is a COM or WMI server issue.
Can anyone shed any light ?
class Console
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
System.Management.ManagementPath lWMIPath = null ;
System.Management.ManagementScope lWMIScope = null ;
System.Management.ObjectQuery lWMIWQL = null ;
System.Management.ManagementOperationObserver lWMIObserver =
null ;
lWMIPath = new System.Management.ManagementPath(
"\\\\remote-machine\\root\\cimv2" ) ;
lWMIScope = new System.Management.ManagementScope() ;
lWMIScope.Path = lWMIPath ;
lWMIScope.Options.Timeout = new System.TimeSpan( 0, 0, 0, 30 ) ;
lWMIObserver = new
System.Management.ManagementOperationObserver() ;
lWMIObserver.ObjectReady += new
System.Management.ObjectReadyEventHandler( ObjectReady ) ;
lWMIObserver.Completed += new
System.Management.CompletedEventHandler( Completed ) ;
lWMIWQL = new System.Management.ObjectQuery();
lWMIScope.Options.Authentication =
System.Management.AuthenticationLevel.Connect ;
using( System.Management.ManagementObjectSearcher lWMISearcher =
new System.Management.ManagementObjectSearcher( lWMIScope, lWMIWQL ) )
{
lWMISearcher.Query.QueryLanguage = "WQL" ;
lWMISearcher.Query.QueryString = "SELECT Name from
Win32_ComputerSystem" ;
lWMISearcher.Options.ReturnImmediately = true ;
lWMISearcher.Options.Timeout = new System.TimeSpan( 0,0,0,4 ) ;
lWMISearcher.Get( lWMIObserver ) ; // this line hangs forever ...
}
}
internal static void ObjectReady( object aSender,
System.Management.ObjectReadyEventArgs aArgs )
{
}
internal static void Completed( object aSender,
System.Management.CompletedEventArgs aArgs )
{
}
}
Using v1.1 .Net on 2k3 Server