[英]Can't access a Console hosted WCF service from a remote client on LAN
For some days now, i'm trying to access my WCF Service from another computer on my LAN and just can't access it. 几天以来,我一直在尝试从LAN上的另一台计算机访问WCF服务,但无法访问它。
Locally it works fine though. 在本地,虽然工作正常。
Majority of the similar questions i could find are using IIS to host the service. 我可以找到的大多数类似问题都是使用IIS托管服务。
I tried to shut down the firewall but i couldn't get any effect. 我试图关闭防火墙,但没有任何效果。
Here are the config files, please ask if you need more : 这是配置文件,请询问您是否需要更多:
Client's App.config : 客户端的App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<system.serviceModel>
<client>
<endpoint name="default"
address="http://myhostIP:3100/"
binding="basicHttpBinding"
contract="ServiceInterface.IService"/>
</client>
</system.serviceModel>
</configuration>
Here is the Host App.config : 这是主机App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<system.serviceModel>
<services>
<service name="ServiceTest.Service">
<endpoint address="http://0.0.0.0:3100"
contract="ServiceInterface.IService"
binding="basicHttpBinding"/>
</service>
</services>
</system.serviceModel>
</configuration>
If you guys got any ideas... I couldn't find any informations 如果你们有什么主意...我找不到任何信息
EDIT : 编辑:
I'm using a console application to host the service 我正在使用控制台应用程序托管服务
Telnet connection from local and remote hosts are working 来自本地和远程主机的Telnet连接正常
EDIT 2 : 编辑2:
I just seen that i made a mistake copying the App.config file. 我只是看到复制App.config文件时出错。 The binding type should be wsDualHttpBinding
instead of basicHttpBinding
绑定类型应该是wsDualHttpBinding
而不是basicHttpBinding
I also could get an error message : 我也会收到错误消息:
First one is that the "Caller couldn't identicate itself to the WCF service" 第一个是“呼叫者无法向WCF服务标识自己”
I tried then to set the security to none (for troubleshooting purposes) and i only got a timeout exception 然后,我尝试将安全性设置为none(出于故障排除的目的),并且我只有一个超时异常
EDIT 3 : 编辑3:
In a console app : 在控制台应用程序中:
static void Main(string[] args)
{
ServiceHost host = new ServiceHost(typeof(ServiceTest.Service));
host.Open();
Console.WriteLine("Server Started");
Console.ReadLine();
}
Edit 4: 编辑4:
The complete solution is available here https://github.com/sidewinder94/smallChatSolution 完整的解决方案可在这里https://github.com/sidewinder94/smallChatSolution
Here is the solution for your issue. 这是您的问题的解决方案。
Client's app config 客户端的应用程序配置
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<system.serviceModel>
<client>
<endpoint name="default"
contract="ChatDllContracts.IService"
binding="netTcpBinding"
address="net.tcp://myHostIp:3100/"
bindingConfiguration="mynet"/>
</client>
<bindings>
<netTcpBinding>
<binding name="mynet" sendTimeout="00:00:05" portSharingEnabled="true">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>
ChatServer's app.config ChatServer的app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<system.serviceModel>
<services>
<service name="ChatDll.Service">
<endpoint contract="ChatDllContracts.IService"
binding="netTcpBinding"
address="net.tcp://localhost:3100"
bindingConfiguration="mynet"/>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="mynet" sendTimeout="00:00:05" portSharingEnabled="true">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>
Please keep in mind that you need to enable the Net.Tcp Port Sharing Service (on the server & client side) in order to get it working. 请记住,您需要启用Net.Tcp端口共享服务 (在服务器和客户端),以使其正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.