I have next code:
private ManagementGroup ConnectToManagementGroup(string serverName, string domain, string userName, string password)
{
var settings = new ManagementGroupConnectionSettings(serverName)
{
UserName = userName,
Domain = domain,
Password = password.ToSecureString()
};
var managementGroup = ManagementGroup.Connect(settings);
if (!managementGroup.IsConnected)
{
throw new Exception($"Can't connect to {serverName} SDK service.");
}
return managementGroup;
}
The code works fine.
But if my SCOM server is down then connection takes one minute before throwing a TimeOut exception.
I have found two properties InactivityTimeout and SendReceiveTimeout in ManagementGroupConnectionSettings class.
I have tried to use these properties to change default TimeOut value.
But unfortunately it doesn't work.
Also I can't find any documentations about connection TimeOut for SCOM SDK.
I have reviewed many links: here, here and here...
But there was no answer for my issue...
How can I set TimeOut for connection myself?
Short answer: it's not possible to set the connect timeout.
Long answer. Microsoft uses
DuplexChannelFactoryclass for SDK Data Layer connection. This class has 7 different timeout settings: Explaination of different timeout types. The actual code, Microsoft creates an instance of Channel Factory class is below:They use custom binding object
internal class IndigoCustomBinding : Binding, which doesn't override/defineOpenTimeoutproperty, so this timeout value is left defaulted from the originalBindingclass.