我在多线程环境中调用 web 服务。由于操作超时或错误请求,我的很多调用都失败了,但如果我以线性方式执行,则没有任何调用失败,这意味着使用多线程调用 web 服务存在问题。经过大量分析,我发现并发连接的限制导致这些异常,所以我通过添加以下代码来修复它。
ServicePointManager.DefaultConnectionLimit = 2 * _ThreadCount;
Run Code Online (Sandbox Code Playgroud)
我不知道增加这个限制可能有什么缺点。默认情况下,连接限制为 2。如果有人知道任何缺点,请告诉我。
我正在我的 asp.net 应用程序中编写 WebEvent,它在我的开发和生产区域都运行良好。但是,当我分析过去几个月生产服务器中的事件日志时。我看到下面的事件
The following exception was thrown by the web event provider 'EventLogProvider' in the application '/(MyApplicationName)' (in an application lifetime a maximum of one exception will be logged per provider instance):
System.Web.HttpException (0x80004005): The EventLogWebEventProvider provider failed to log an event with the error code 0x80070057.
at System.Web.Management.EventLogWebEventProvider.ProcessEvent(WebBaseEvent eventRaised)
at System.Web.Management.WebBaseEvent.RaiseInternal(WebBaseEvent eventRaised, ArrayList firingRuleInfos, Int32 index0, Int32 index1)
Run Code Online (Sandbox Code Playgroud)
虽然发生率很低,但我仍然很好奇为什么会发生这种情况。我试着做一些研究,发现下面的链接 http://forums.iis.net/t/1201176.aspx?IIS+Keep+hanging
根据此链接,我可能在写入事件日志时传递了一些无效参数。但是我仔细检查了我的 EventLog.WriteEntry 方法,我在我的应用程序中只在几个地方使用它,而且,我正在传递静态字符串消息。如果参数无效,则每次尝试写入事件时都应该发生。
任何人都可以帮助我了解此事件的可能原因。使用 EvenLog 时是否有任何已知问题?