无法从远程计算机获取元数据,但本地可以
这是我的 App.config:
<?xml version="1.0"?>
<configuration>
<runtime>
</runtime>
<system.serviceModel>
<diagnostics performanceCounters="Default" />
<bindings />
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<behaviors>
<endpointBehaviors>
<behavior name="CrossDomainServiceBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="AService.AServBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MyService.MyServiceBehavior" name="MyService.MyServ">
<endpoint address="MyService" behaviorConfiguration="" binding="netTcpBinding" contract="AService.IAServ" isSystemEndpoint="false" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
如您所见,没有什么特别的。我只想创建具有 TCP 绑定和传输元数据信息能力的简单服务。我使用 basicHttpBinding 取得了成功,一切都很顺利。 下面是使用基地址创建服务实例的代码:
Console.WriteLine("net.tcp://" + _bindAddress + "/");
ServiceHost myserviceHost = new ServiceHost(typeof(MyService), new Uri(String.Concat("net.tcp://", _bindAddress, "/")));
myserviceHost.Open();
_bindAddress
是来自自定义服务配置 XML 文件的字符串。我正在尝试将服务绑定到 IP 地址 172.19.0.102:8733
的内部网络接口。然后我尝试使用 WcfTestClient 从服务计算机上的地址 127.0.0.1:8733
获取服务元数据,一切都很好。但随后我尝试通过 Internet 获取目标远程计算机上的服务元数据,却收到代码 10051 的 TCP 错误
。 我的目标是让服务正常运行并通过互联网为任何客户发布元数据。防火墙和其他网络东西没有问题。看来我需要进行一些配置编辑,以允许服务与每个人共享元数据。 提前致谢!
帖子编辑:
这是我的尝试: 1) 服务配置为绑定在 172.19.0.102:8733
。 A. WCF 测试客户端尝试从地址 net.tcp://127.0.0.1:8733/
获取托管计算机上的元数据失败,TCP 错误代码 10061
。 B. 在同一台计算机上,WCF 客户端尝试从 net.tcp://172.19.0.102:8733
获取元数据,并且工作正常。 C. WCF 测试客户端尝试从地址 net.tcp://192.168.1.2:8733/
(它是服务的计算机 IP 地址)获取 LAN 中另一台计算机上的元数据,出现错误 TCP 错误代码10061。
So here's my App.config:
<?xml version="1.0"?>
<configuration>
<runtime>
</runtime>
<system.serviceModel>
<diagnostics performanceCounters="Default" />
<bindings />
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<behaviors>
<endpointBehaviors>
<behavior name="CrossDomainServiceBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="AService.AServBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MyService.MyServiceBehavior" name="MyService.MyServ">
<endpoint address="MyService" behaviorConfiguration="" binding="netTcpBinding" contract="AService.IAServ" isSystemEndpoint="false" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
As you can see there's nothing special. I just want to create simple service with tcp binding and ability to transmit metadata information. I had success with same one using basicHttpBinding
and everything was going OK.
Here's the code that creates service instance with baseaddress:
Console.WriteLine("net.tcp://" + _bindAddress + "/");
ServiceHost myserviceHost = new ServiceHost(typeof(MyService), new Uri(String.Concat("net.tcp://", _bindAddress, "/")));
myserviceHost.Open();
_bindAddress
is a string that comes from custom service configuration XML file. I'm trying to bind service to internal network interface at IP address 172.19.0.102:8733
. Then I'm trying to get service metadata using WcfTestClient from address 127.0.0.1:8733
on service's machine and everyting is fine. But then I trying to obtain service's metadata on target remote machine over Internet I getting the TCP error with code 10051
.
My goal is to get service working and publishing metadata over Internet for any client. There's no issues with firewalls and other network stuff. It seems like I need some configuration edits to allow service share metadata with everyone.
Thanks in advance!
POST EDIT:
Here is my tryings:
1) Service configured to bind at 172.19.0.102:8733
.
A. WCF Test Client tryes to obtain metadata on hosted machine from address net.tcp://127.0.0.1:8733/
failed with TCP error code 10061
.
B. On the same machine WCF Client tryes to obtain metadata from net.tcp://172.19.0.102:8733
and it's working OK.
C. WCF Test Client tryes to obtain metadata on another machine in LAN from address net.tcp://192.168.1.2:8733/
(it's service's machine IP address) gives an error TCP error code 10061
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该错误意味着:网络无法访问,这很可能是真正发生的情况。您的 IP 地址属于专用网络范围,这些地址永远不能直接从 Internet/WAN 寻址 - 它们仅用于 LAN 中的本地使用。要通过互联网访问此类地址,您必须配置公开的路由器/网关以接受连接并将其转发到您的内部设备 = NAT/端口转发等。
That error means: Network is unreachable an that is most probably what really happens. Your IP address belongs to private network range and these addresses can never be addressed directly from Internet / WAN - they are only for local usage in LAN. To access such address over internet you must configure your publicly exposed router / gateway to accept the connection and forward it to your internal device = NAT / port forwarding, etc.