C# WCF试图公开nettcp端点;TCP错误代码10061:无法建立连接,因为目标计算机主动拒绝它
我不明白这里有什么问题。我的wsHttpBinding工作正常。这是我的配置。非常感谢您的帮助C# WCF试图公开nettcp端点;TCP错误代码10061:无法建立连接,因为目标计算机主动拒绝它,c#,.net,wcf,C#,.net,Wcf,我不明白这里有什么问题。我的wsHttpBinding工作正常。这是我的配置。非常感谢您的帮助 <?xml version="1.0"?> <configuration> ..... <system.serviceModel> <services> <service behaviorConfiguration="DataService.Service1Behavior" name="O
<?xml version="1.0"?>
<configuration>
.....
<system.serviceModel>
<services>
<service behaviorConfiguration="DataService.Service1Behavior"
name="ODHdotNET.DataService">
<endpoint
address=""
binding="wsHttpBinding"
bindingConfiguration="largeTransferwsHttpBinding"
contract="ODHdotNET.IDataService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="net.tcp://139.149.141.221:8001/DataService.svc"
binding="netTcpBinding"
contract="ODHdotNET.IDataService"/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://139.149.141.221:8000/DataService.svc" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="largeTransferwsHttpBinding2"
maxReceivedMessageSize="5000000" maxBufferPoolSize="5000000">
<security mode ="Message">
<message clientCredentialType="UserName"/>
</security>
</binding>
<binding name="largeTransferwsHttpBinding"
maxReceivedMessageSize="5000000" maxBufferPoolSize="5000000" />
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="DataService.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
.....
编辑:我在Windows服务中自托管;我没有使用IIS。您需要向IIS添加TCP支持。 要特别启用TCP、MSMQ或命名管道通信,请执行配置相关协议支持的附加步骤。对于TCP通信,使用Appcmd命令行实用程序将默认网站绑定到net.TCP端口。Appcmd是一个IIS实用程序,可用于管理虚拟站点、目录、应用程序和应用程序池
%windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" -
+bindings.[protocol='net.tcp',bindingInformation='808:*']
要支持其他协议,请运行其他命令,为默认网站启用这些协议。此时,您已经在站点级别配置了net.tcp协议
%windir%\system32\inetsrv\appcmd.exe set app "Default Web Site/OrderServiceHost"
/enabledProtocols:http,net.tcp
有关更多详细信息,请查看以下内容:
您的意思是WCF客户端抛出此错误吗? 如果是: 请在命令提示下运行以下命令: netstat-ona |查找“8001”
如果返回数据,请发布它确保windows防火墙中的端口已打开在客户端应用程序中调用方法时,确保主机正在运行 非常感谢。请查看我的编辑,我没有使用IIS托管,但我将阅读此内容并查看它是否是潜在客户。我配置了错误的配置文件。但是,现在我已配置了正确的配置,因此出现以下错误:“元数据包含无法解析的引用:'net。tcp://139.149.141.221:8001/DataService.svc'. 套接字连接已中止。这可能是由于处理消息时出错、远程主机超过接收超时或基础网络资源问题造成的。本地套接字超时为“00:05:00”。远程主机已强制关闭现有连接“响应下面的帖子,我已运行netstat并获得:TCP 139.149.141.221:8001 0.0.0.0:0侦听4960这不是防火墙,没有端口被阻止。如果我尝试使用一个我知道有效的端口(例如,对于http和关闭http端点)它仍然不工作。好的,因此主机已启动并运行,此端口上没有其他程序。现在,我认为您提供的基址太具体了。是否可以尝试删除“:8000/DataService.svc”部分?(基址由端点使用。它们添加uri的其余部分)Hi@Roel看起来你忘了把端口号用双引号括起来,比如:“8001”