[英]An error occurred while receiving the HTTP response to wcfservice.svc. This could be due to the service endpoint binding not using the HTTP protocol
I have a wcf service deployed under IIS 6.0. 我在IIS 6.0下部署了wcf服务。 The service method accepts a list of objects and return the same list.
服务方法接受对象列表并返回相同的列表。
List<CustomObject> ProcessImageData(List<CustomObject> lstData)
The object may contain large amount of html data. 该对象可能包含大量的html数据。 The service currently takes hardly a few seconds to fulfill the request but I am getting a tons of following 2 exceptions.
该服务目前几乎不需要几秒钟即可完成请求,但是我收到了以下两个例外。
"The request channel timed out while waiting for a reply after 00:00:59.9989999. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout." “请求通道在00:00:59.9989999之后等待回复时超时。增加传递给Request调用的超时值或增加Binding上的SendTimeout值。分配给此操作的时间可能是超时。”
"An error occurred while receiving the HTTP response to http://MyService.svc . This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details." “接收到对http://MyService.svc的HTTP响应时发生错误。这可能是由于服务端点绑定未使用HTTP协议引起的。这也可能是由于HTTP请求上下文被服务器中止了(可能是由于服务已关闭)。请参阅服务器日志以了解更多详细信息。”
Here is how my config files looks like. 这是我的配置文件的样子。
<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>
One of the exceptions propose to increase the sendTimeout vakue which is currently set to 1 minute. 一种例外情况是建议增加sendTimeout vakue(当前设置为1分钟)。 I increased it but it didn't seem to improve anything and I still get these exceptions.
我增加了它,但似乎没有任何改善,但我仍然得到这些例外。
Question: Why am I getting these exceptions and what can I change to prevent this ? 问题:为什么我会收到这些例外情况,我可以做些什么更改以防止发生这种情况?
Also, Here is an exception which is logged into Event Log on IIS server. 另外,这是一个例外,已记录到IIS服务器上的事件日志中。
Exception Type: System.ArgumentException Message: Parameter is not valid. 异常类型:System.ArgumentException消息:参数无效。 ParamName: NULL Data: System.Collections.ListDictionaryInternal TargetSite: Void .ctor(Int32, Int32, System.Drawing.Imaging.PixelFormat) HelpLink: NULL Source: System.Drawing
ParamName:NULL数据:System.Collections.ListDictionaryInternal TargetSite:Void .ctor(Int32,Int32,System.Drawing.Imaging.PixelFormat)帮助链接:NULL来源:System.Drawing
StackTrace Information StackTrace信息
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format) at System.Drawing.Bitmap..ctor(Int32 width, Int32 height) at WcfService.CreateBitmap(WebBrowser& browser) in C:_tfs\\ImagingSystem\\Development\\Dev\\Source\\Wcf\\WcfServices\\HtmlToPngService\\HtmlToPngService.svc.cs:line 126 在System.Drawing.Bitmap..ctor(Int32宽度,Int32高度,PixelFormat格式)在C:_tfs \\ ImagingSystem \\开发\\ Dev \\ Source \\ Wcf \\ WcfServices \\ HtmlToPngService \\ HtmlToPngService.svc.cs:line 126
You need to increase the timeout values in web.config (services), too. 您还需要增加web.config(服务)中的超时值。 Something like this:
像这样:
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IHtmlToImageService"
openTimeout="00:10:00"
closeTimeout="00:10:00"
sendTimeout="00:10:00"
receiveTimeout="00:10:00">
</binding>
</wsHttpBinding>
</bindings>
I suggest to review the following link: 我建议查看以下链接:
https://msdn.microsoft.com/en-us/library/hh924831(v=vs.110).aspx https://msdn.microsoft.com/zh-CN/library/hh924831(v=vs.110).aspx
There can be a couple of things that can go wrong in this scenario. 在这种情况下,可能有几处可能出错。 First, WCF is built to be very secure in its default configuration.
首先,WCF的默认配置非常安全。 That is why there is a limit to size of incoming requests.
这就是为什么传入请求的大小受到限制的原因。 That limit is default rather small (65536 bytes).
该限制默认是相当小的(65536字节)。 If your requests are larger than that, you need to configure the maxReceivedMessageSize and set it to the maximum number of bytes you want to support.
如果您的请求大于该请求,则需要配置maxReceivedMessageSize并将其设置为要支持的最大字节数。 Both on the server for incoming requests and the client for incoming responses.
在服务器上用于传入请求,在客户端上均用于传入响应。 This is the likely cause for the second error, and you should be able to find a reference to this in the logging of your service.
这可能是第二个错误的原因,您应该能够在服务的日志中找到对此的引用。
you can first analyzed the exception. 您可以先分析异常。 Do following exception Setting in visual studio and enable the "Common language Runtime exception".
在Visual Studio中执行以下异常设置,并启用“公共语言运行时异常”。
mostly you can get the in depth details of exception using this. 大多数情况下,您可以使用此方法获得异常的详细信息。 I got this exception because one of the field is mandatory in my model which I am getting null in response and due to this on client side my object is not able to get deserialized properly.
我收到此异常的原因是,在我的模型中该字段是强制性的,作为响应,我得到了null,并且由于在客户端,我的对象无法正确反序列化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.