Silverlight客户端和WCF服务之间的间歇性通信问题
我有一个 Silverlight 4 应用程序,它与运行 IIS 7.5 的服务器进行通信,该服务器托管着许多我自己的 WCF 服务。该应用程序在 99% 的时间内运行良好,但用户报告说该应用程序每天都会冻结几次,或者在应用程序的各个点上都会生成错误消息。
我打开 WCF 跟踪并发生以下错误:
<Exception>
<ExceptionType>System.ServiceModel.ProtocolException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>The number of bytes available is inconsistent with the HTTP Content-Length header. There may have been a network error or the client may be sending invalid requests. </Message>
<StackTrace>
at System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(Stream inputStream)
at System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(Exception& requestException)
at System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context, Action callback)
at System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state)
at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace>
</Exception>
然后我在用户的计算机上运行 Fiddler 并发现发生以下错误:
HTTP/1.1 504 Fiddler - Receive Failure
Content-Type: text/html; charset=UTF-8
Connection: close
Timestamp: 18:24:21.941
ReadResponse() failed: The server did not return a response for this request.
从一些研究来看,客户端和服务器之间似乎存在一些通信问题。该服务器是一个虚拟专用服务器,我从未遇到过任何问题,并且从查看日志来看,它从未耗尽处理器/内存。
我的问题是: 1. 我可以做些什么来更详细地跟踪正在发生的事情,或者我可以调整任何与 IIS 或服务器相关的内容以避免此错误 2. 在我的 Silverlight 应用程序中,有什么方法可以等待特定的时间(例如 30 秒),如果没有收到响应,则取消当前请求并重试
I have a Silverlight 4 application that communicates with a server running IIS 7.5 that hosts a number of my own WCF services. The application runs happily 99% of the time but users reports that a few times a day the application will freeze or error messages will be generated at various points in the application.
I turned on WCF tracing and the following errors occur:
<Exception>
<ExceptionType>System.ServiceModel.ProtocolException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>The number of bytes available is inconsistent with the HTTP Content-Length header. There may have been a network error or the client may be sending invalid requests. </Message>
<StackTrace>
at System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(Stream inputStream)
at System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(Exception& requestException)
at System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context, Action callback)
at System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state)
at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace>
</Exception>
I then ran Fiddler on a user's machine and found the following errors were occurring:
HTTP/1.1 504 Fiddler - Receive Failure
Content-Type: text/html; charset=UTF-8
Connection: close
Timestamp: 18:24:21.941
ReadResponse() failed: The server did not return a response for this request.
From some research it looks like there is some communication problem between the client and the server. The server is a Virtual Private server which I have never had any trouble with and from looking at the logs it is never maxed out processor/memory wise.
My questions are:
1. Is there anything I can do to track what is happening in more detail or anything IIS or server related I can adjust to avoid this error
2. In my Silverlight application is there some way I can wait a specific amount of time (e.g. 30 seconds) and if no response has been recieved cancel the current request and try again
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在以下网页中解决了类似的问题:
WCF 服务出错可用字节数与 HTTP Content-Length 标头不一致
A similar question is solved in the following webpage:
Error at WCF Service The number of bytes available is inconsistent with the HTTP Content-Length header