如何设置我的 WCF 服务以便远程客户端能够访问 [英] How to set up my WCF service to be able to be accessed by remote clients
问题描述
我有一个 WCF 服务托管在 Windows 服务中,我可以连接到它并在使用同一台机器时很好地使用它的服务,但是当我尝试在远程机器上运行我的客户端时,它超时并且不会连接.我以为我可以用服务机器的 IP 而不是 localhost 来更新客户端的 app.config 文件,但这不起作用.这是客户端的 app.config:
I have a WCF service that is being hosted in a windows service and I can connect to it and consume its services just fine when using the same machine, but when I try to run my client on a remote machine it times out and won't connect. I thought I could just update the app.config file for the client with the IP of the service machine instead of localhost, but that didn't work. Here is the app.config of the client:
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IWCFService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.1.141:8731/Design_Time_Addresses/WCF/WCFService/"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IWCFService"
contract="WCFService.IWCFService" name="WSDualHttpBinding_IWCFService">
<identity>
<dns value="192.168.1.141" />
</identity>
</endpoint>
</client>
这里是服务的 app.config:
And here is the app.config of the serivice:
<system.serviceModel>
<services>
<service name="WCF.WCFService" behaviorConfiguration="WCFBehavior">
<endpoint address="" binding="wsDualHttpBinding" contract="WCF.IWCFService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
bindingConfiguration=""
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
我需要在服务端做些什么来允许远程连接,还是我没有正确配置客户端?
Is there something I need to do on the service side to allow remote connections or am I just no configuring the client correctly?
推荐答案
这似乎是一个简单的建议,但您是否检查过服务器上的防火墙以确保它没有阻止通信?我花了三天的时间把头撞在墙上,直到我注意到这一点.
This may seem like a simplistic suggestion, but have you checked the firewall on your server to make sure that it's not blocking communications? I spent three days banging my head on a wall until I noticed that.
这篇关于如何设置我的 WCF 服务以便远程客户端能够访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!