简体   繁体   English

WCF超时错误,代码运行正常

[英]WCF timeout error with code running fine

I have a project that uses a WCF service to do some database queries, builds an "Environment" object (which consists of different database class objects) and returns it inside a "Workspace" object to the client. 我有一个使用WCF服务进行一些数据库查询,构建“环境”对象(由不同的数据库类对象组成)并将其在“工作空间”对象内返回给客户端的项目。 It's been running fine. 运行良好。

I added another "Database" type to the service with all the correct contract and method updates. 我向服务中添加了另一个“数据库”类型,其中包含所有正确的合同和方法更新。 Now when I call the method the client times out after 1 minute. 现在,当我调用该方法时,客户端将在1分钟后超时。 In debugging it take about 3-5 seconds to hit the end of the service method. 在调试中,大约需要3-5秒才能达到服务方法的结尾。 Then nothing happens for the rest of the minute until on the client side we see a timeout problem. 然后剩下的一分钟都什么都没有发生,直到在客户端我们看到超时问题。 There are no errors/exceptions thrown. 没有引发任何错误/异常。

Please see below: 请看下面:

Calling from client: 致电客户:

490  m_ScanWorkspace = m_Connection.ScanProxy.CreateEnvironments

End of service method: 服务终止方法:

477   return tWorkspace;
478 }

It takes 3-5 seconds to get to line 478 in the service. 到达服务中的478行需要3-5秒。 F10 shows it's complete. F10显示它已经完成。

Nothing happens until 1 minute later when line 490 in the client shows a timeout error. 直到1分钟后客户端中的第490行显示超时错误,然后什么都没有发生。 while debugging I can see a valid object in tWorkspace. 调试时,我可以在tWorkspace中看到一个有效的对象。

Firstly, set up WCF tracing using the Diagnostics namespace. 首先,使用Diagnostics名称空间设置WCF跟踪 Just use the first example on that tutorial and WCF will dump out a log of all activity, which you can open up in the log viewer. 只需使用该教程的第一个示例,WCF就会转储所有活动的日志,您可以在日志查看器中打开该日志。 It will tell you exactly where the call is failing, which will help you pinpoint the problem. 它会告诉您呼叫失败的确切位置,这将帮助您查明问题所在。

WCF is great, but the error messages it gives are cryptic and often close to useless. WCF很棒,但是它给出的错误消息是含糊的,通常几乎是无用的。 A timeout after 1 minute doesn't necessarily mean what a timeout would normally mean - ie couldn't find the server. 1分钟后的超时并不一定意味着超时通常意味着什么-即找不到服务器。 It could be other issues. 这可能是其他问题。

More than likely there will be a threshold exceeded which causes the response object to be incomplete. 很有可能会超过阈值,从而导致响应对象不完整。 This could be array length, string content length, message size, and so on. 这可以是数组长度,字符串内容长度,消息大小等。 You will find some of these detailed here: https://stackoverflow.com/a/480191/146077 您将在此处找到一些详细信息: https : //stackoverflow.com/a/480191/146077

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM