1

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?

Alexander I.
  • 2,380
  • 3
  • 17
  • 42

1 Answers1

0

Short answer: it's not possible to set the connect timeout.

Long answer. Microsoft uses DuplexChannelFactory class 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:

DuplexChannelFactory<T> duplexChannelFactory = new DuplexChannelFactory<T>((object) this.clientCallback, (Binding) new IndigoCustomBinding(false, this.connectionSettings.SendReceiveTimeout, this.connectionSettings.InactivityTimeout), new EndpointAddress(new Uri(string.Format((IFormatProvider) CultureInfo.InvariantCulture, endpointUri, new object[1]
  {
    (object) this.connectionSettings.ServerName
  })), EndpointIdentity.CreateSpnIdentity(string.Format((IFormatProvider) CultureInfo.InvariantCulture, spn, new object[1]
  {
    (object) this.connectionSettings.ServerName
  })), new AddressHeaderCollection()));

They use custom binding object internal class IndigoCustomBinding : Binding, which doesn't override/define OpenTimeout property, so this timeout value is left defaulted from the original Binding class.

Max
  • 751
  • 6
  • 10