【发布时间】:2016-03-09 20:38:00
【问题描述】:
我在 IIS 6.0 下部署了一个 wcf 服务。 service 方法接受对象列表并返回相同的列表。
List<CustomObject> ProcessImageData(List<CustomObject> lstData)
该对象可能包含大量 html 数据。该服务目前几乎不需要几秒钟即可完成请求,但我收到了大量以下 2 个异常。
“请求通道在 00:00:59.9989999 之后等待回复时超时。增加传递给 Request 调用的超时值或增加 Binding 上的 SendTimeout 值。分配给此操作的时间可能是较长超时的一部分。”
“在接收到http://MyService.svc 的 HTTP 响应时发生错误。这可能是由于服务端点绑定未使用 HTTP 协议。这也可能是由于 HTTP 请求上下文被服务器中止(可能是由于到服务关闭)。有关详细信息,请参阅服务器日志。”
这是我的配置文件的样子。
web.Config(服务)文件
<service behaviorConfiguration="WcfServices.Service1Behavior" name="WcfServices.HtmlToImageService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="LargeSizeMessages" contract="WcfServices.IHtmlToPngService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
<behaviors>
<serviceBehaviors>
<behavior name="WcfServices.Service1Behavior">
<serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000" maxConcurrentInstances="1000"/>
<serviceMetadata httpGetEnabled="true"/>
<dataContractSerializer maxItemsInObjectGraph="6553500"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</behaviors>
<wsHttpBinding>
<binding name="LargeSizeMessages"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas
maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
</binding>
</wsHttpBinding>
客户端配置文件
<wsHttpBinding>
<binding name="WSHttpBinding_IHtmlToImageService" closeTimeout="00:10:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
其中一个例外建议增加当前设置为 1 分钟的 sendTimeout vakue。我增加了它,但它似乎没有改善任何东西,我仍然得到这些例外。
问题: 为什么我会收到这些异常,我可以更改什么来防止这种情况发生?
另外,这是一个记录在 IIS 服务器上的事件日志中的异常。
异常类型:System.ArgumentException 消息:参数无效。 参数名称:NULL 数据:System.Collections.ListDictionaryInternal TargetSite:无效.ctor(Int32,Int32,System.Drawing.Imaging.PixelFormat) 帮助链接:NULL 来源:System.Drawing
堆栈跟踪信息
在 System.Drawing.Bitmap..ctor(Int32 宽度, Int32 高度, PixelFormat 格式) 在 System.Drawing.Bitmap..ctor(Int32 宽度,Int32 高度) 在 C:_tfs\ImagingSystem\Development\Dev\Source\Wcf\WcfServices\HtmlToPngService\HtmlToPngService.svc.cs:line 126 中的 WcfService.CreateBitmap(WebBrowser& browser) 处
【问题讨论】:
-
看起来服务端发生了一些灾难性的异常,导致服务中断。检查 Windows 事件日志并查看是否记录了任何异常。
-
另一件事 - List
ProcessImageData(List lstData) - WCF 将所有列表/IEnumerables 转换为数组。所以这是一个等价的服务操作契约CustomObject[] ProcessImageData(CustomObject[] lstData) -
正确,但它对我所面临的任何事情有何影响?
标签: c# web-services wcf