问题描述
我有一个公开 wcf 服务的插件.如果我使用 WCFStorm 测试此服务,则一切正常.我马上得到答复.当我尝试使用加载插件的应用程序中的服务时,我会超时.
I have a plugin that exposes a wcf service. if I test this service using WCFStorm, everything works fine. I get a response right away. When I try to consume the service from the application that loaded the plugin I get a time out.
ProgrammingMaster_ServiceClient aClient = new ProgrammingMaster_ServiceClient();
aClient.Endpoint.Address = new EndpointAddress("http://localhost:8081/ProgrammingMaster/PM_Service");
aClient.BeginProgrammingSession(0x01);
aClient.Close();
是我用来消费服务的代码.ProgrammingMaster_SERviceClient 由 svcutil.exe 生成.
Is the code i'm using to consume the service. ProgrammingMaster_SErviceClient is generated by svcutil.exe.
如果我删除该行,我会遇到同样的问题
I get the same problem if i remove the line
aClient.Endpoint.Address = new EndpointAddress("http://localhost:8081/ProgrammingMaster/PM_Service");
我不确定应该从哪里开始调试.
I'm not really sure where I should be looking to start debugging this.
被调用的服务在不同的网络上发送消息.当我通过 wcfstorm 调用它时,我可以看到服务发送的消息.所以我知道服务正常工作.
the service being called sends a message on a different network. When I call it through wcfstorm I can see the message being sent by the service. so i know the service works correctly.
当我从我的应用程序调用导致超时的服务时,我做错了什么.
What am i doing wrong when I call the service from my application that is causing a time out.
超时到期后(我正在捕获并记录异常),该服务会像预期的那样在另一个网络上发送其消息.
after the time out expires (I'm catching and logging the exception), the service sends its message on the other network like its supposed to.
编辑 2:希望这是一个更好的解释.
Edit 2: Hopefully this is a better explanation.
所以我有一个插件,它公开一个 Web 服务,并使用一个不同的 Web 服务.因此,插件基本上连接到特殊网络上的对象,然后通过使用 Web 服务传递该对象的属性值.
So I have a plugin which exposes a web service, and consumes a different web service.So the plugin basically connects to an object on a special network, then passes that objects property values by consuming a web service.
我有一个应用程序,它公开插件用来更新远程对象值的 Web 服务,并使用插件公开的 Web 服务将命令传递给远程对象.
I have an application which exposes the web service the plugin uses to give updates of the remote objects values, and consumes a web service exposed by the plugin to pass commands to the remote object.
插件向应用程序发送更新时没有超时问题.当应用程序使用 Web 服务通过插件向远程对象发送命令时,出现超时错误.超时到期后,将执行该命令.所以web服务被成功调用.我想我只是没有得到回复?
There are no timeout issues when the plugin sends updates to the application. I'm getting a timeout error when the application uses the web service to send a command to the remote object via the plugin. After the timeout expires the command is executed. So the web service is being called successfully. I guess I'm just not getting a response back?
编辑 3:这是我的应用程序配置文件.我将发送超时降低到 00:00:01,这样等待时间就不会那么长,但我真的很想修复它,这样它就不必每次都超时.
Edit 3:here is my app config file. I lowered the send timeout to 00:00:01 so that the wait isn't so long, but I'd really like to fix it so it doesn't have to timeout every time.
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IProgrammingMaster_Service" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:00:01" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="">
<extendedProtectionPolicy policyEnforcement="Never"/>
</transport>
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8081/ProgrammingMaster/PM_Service" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IProgrammingMaster_Service" contract="IProgrammingMaster_Service" name="WSHttpBinding_IProgrammingMaster_Service">
<identity>
<userPrincipalName value="[email protected]"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
推荐答案
哦...
是的,超时只发生在客户端和服务器都是相同的应用程序.
重要的问题是客户端和服务运行在同一个线程上吗?
The important question is are the client and service running on the same thread?
如果是这样,那很可能是您的问题.尝试在自己的线程中启动服务,看看是否能解决问题.
If so, that's likely your problem. Try spinning up the service in its own thread and see if that sort out the problem.
这篇关于WCF 服务超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!