简体   繁体   English

无法从LAN上的远程客户端访问控制台托管的WCF服务

[英]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.

相关问题 WCF 服务在从控制台托管的浏览器中不起作用 - WCF service is not working in browser hosted from a console 无法从客户端连接到WCF服务 - Can't connect to WCF service from client 无法从 Windows 服务托管的 wcf 启动 WinWord - Can't launch WinWord from windows service hosted wcf 通过客户端控制台应用程序访问IIS上托管的WCF服务 - Accessing WCF service hosted on IIS by a client console application WCF服务托管在控制台应用程序中 - WCF Service hosted in a Console Application 为什么远程调试不适用于IIS托管的WCF服务? - Why doesn't remote debugging work for WCF service hosted by IIS? 由accoreconsole.exe托管时,客户端无法与WCF服务进行交互 - Client can't interact with WCF-service when it is hosted by accoreconsole.exe Windows Service托管的WCF:从Windows服务回调到客户端 - Windows Service hosted WCF: Callback to client from Windows service 无法在非域上访问服务Windows 7自托管WCF应用程序 - Can't access service Windows 7 self-hosted WCF app on a non-domain 无法从C#中的客户端(控制台应用程序)通过WCF服务(已通过Windows身份验证)访问SQL Server - Unable to access SQL Server from WCF service (Windows authenticated) from client (console application) in C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM