WMI超时 [英] WMI timeout

查看:160
本文介绍了WMI超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.我正在通过WMI收集我公司中服务器的信息.

大多数服务器基于Windows,但是当服务器是Linux或VMWare ESX时,连接超时为3分钟.

我尝试更改连接超时,如下所示:

ConnectionOptions coOpciones = new ConnectionOptions();
coOpciones.Timeout = new TimeSpan(0,0,0,5);



但是仍然需要花费所有3分钟的时间才能将控件返回到表单.

有什么建议吗?

在此先谢谢您.

解决方案

这很奇怪,因为您指定的是连接超时.这意味着它已连接,但是当它尝试执行操作时,它将超时.因此请尝试设置操作超时".

对于VMWare,应该是这种情况,否则无法通过WMI连接到Linux. :)



 // the namespace we are searching in
ManagementScope Scope = new ManagementScope(@"\.\root\cimv2");

// the query we are performing
WqlObjectQuery Query= new WqlObjectQuery("SELECT * FROM meta_class");

// enumeration options to use for the search; set a time-out value
EnumerationOptions Options = new EnumerationOptions();
Options.Timeout = new TimeSpan(0, 0, 10);

// instantiate the searcher object using the scope and query
ManagementObjectSearcher Searcher = new ManagementObjectSearcher(Scope, Query, Options);



您可以在此处 [ ^ ]


是的,在连接之前进行Ping是一个很好的主意.我认为WMI呼叫应在20秒内超时,这3分钟太长了.您是否正在使用任何Web/WCF服务来执行此操作?因为默认情况下3分钟是WCF服务的接收超时值.

网上也有很多人试图解决这些问题,但是没有运气. :-)


因此,让我们尝试以另一种方式思考,

创建一个线程来调用服务器,然后启动自己的计时器对象,当它到期时,终止该线程.还要为每个请求创建单独的线程,因此您的应用将比以前更快地获得结果.可能是并行处理,可以在30秒内完成10台以上的服务器.


Hi. I''m collecting information of the servers in my company through WMI.

Most servers are Windows based, but when the server is Linux, or VMWare ESX, the timeout for the ocnnection is almos 3 minutes.

I''ve tried to change the timeout of the connection as follows:

ConnectionOptions coOpciones = new ConnectionOptions();
coOpciones.Timeout = new TimeSpan(0,0,0,5);



But still continues to spend all the 3 minutes before return the control to the form.

Any suggestions?

Thanks in advance.

解决方案

This is strange, Because what you have specified is Connection Timeout. That means it gets connected, but when it tries to perform an operation, it gets timeout. so try setting Operation Timeout.

This should be the case with VMWare thing, otherwise no way you can connect to the Linux box with WMI. :)

i.e.

 // the namespace we are searching in
ManagementScope Scope = new ManagementScope(@"\.\root\cimv2");

// the query we are performing
WqlObjectQuery Query= new WqlObjectQuery("SELECT * FROM meta_class");

// enumeration options to use for the search; set a time-out value
EnumerationOptions Options = new EnumerationOptions();
Options.Timeout = new TimeSpan(0, 0, 10);

// instantiate the searcher object using the scope and query
ManagementObjectSearcher Searcher = new ManagementObjectSearcher(Scope, Query, Options);



You can get more details about the operation timeout, here[^]


Yes, That Ping before connect is very nice idea. I think the WMI calls should timeout within 20 sec, 3 min is too long. Are you using any Web/WCF service to do this ? because 3 min is default receive time out value for WCF Service.

Also there are many people on the net trying to fix these problem, with no luck. :-)


so lets try to think the other way,

create a thread to call the server and then start your own timer object and when it expire, kill the thread. also create separate thread for each request, so your app will get the result faster than before. might be parallel processing can finish 10+ servers within 30 sec.


这篇关于WMI超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆