net.tcp 使用 .NET 4.0 托管在 Windows 7 虚拟机上的 IIS7.5 中
我有最简单的 WCF 服务,该服务在使用 basicHttp 绑定托管在 IIS 中时可以工作。它有一个名为 DoNothing 的空方法,它不带任何参数并返回 void
void DoNothing()
但是,当我尝试使用 net.tcp 在 IIS 中托管它时,我无法让它工作。
我假设它是配置,因为无论使用什么绑定,相同的服务代码都应该工作。
我启用了非http激活。我使用不同的端口 12345 以避免任何冲突。网站和服务设置为使用 net.tcp 绑定。
Net.Tcp ListenerAdaptor 和 Net.Tcp 端口共享服务正在运行
我可以获取元数据以使用 WcfTestClient 测试该服务。
我收到的错误是
套接字连接已中止。这可能是由于处理消息时出错、远程主机超出接收超时或底层网络资源问题造成的。本地套接字超时为“00:00:59.8597984”。
内部异常是
现有连接被远程主机强制关闭,
我想我已经检查了所有内容。我尝试过在虚拟机上远程和本地调用它,
我只能认为这是一个简单的配置错误或安全问题。虚拟机不在域中。我已经在虚拟机上完全禁用了防火墙。
有没有人遇到同样的问题,并且有解决办法。或者有人有一个非常简单(完整)的示例,说明如何在 IIS 中托管 net.tcp 服务,他们可以发布
这里是我的 web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="PortSharingBinding" portSharingEnabled="true">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="SimpleNetTcpService.Service">
<endpoint address="net.tcp://192.168.0.2:12345/SimpleNetTcpService/Service"
binding="netTcpBinding" bindingConfiguration="PortSharingBinding"
contract="SimpleNetTcpService.IService" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I have the simplest WCF service which works when hosted in IIS using basicHttp binding. It has one empty method called DoNothing which takes no parameters and returns a void
void DoNothing()
However I cannot get it to work when trying to host it in IIS using net.tcp.
I am assuming it is the configuration, as the same service code should work regardless of binding used.
I have enabled non-http activation. I am using a different port 12345 to avoid any clashes. The website and service is set up to use net.tcp binding.
The Net.Tcp ListenerAdaptor and Net.Tcp Port Sharing services are running
I can get the metadata to use WcfTestClient to test the service.
The error I get is
The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.8597984'.
The inner exception is
An existing connection was forcibly closed by the remote host
I thing I have checked everything. I have tried calling it remotely and locally on the virtual machine
I can only think it is a simple config error or a security issue. The virtual machine is not in a domain. I have disabled the firewall completely on the virtual machine.
Has anyone had the same issue, and has a resolution. Or does someone have a very simple (full) example of how to host a net.tcp service in IIS, whih they could post
Here is my web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="PortSharingBinding" portSharingEnabled="true">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="SimpleNetTcpService.Service">
<endpoint address="net.tcp://192.168.0.2:12345/SimpleNetTcpService/Service"
binding="netTcpBinding" bindingConfiguration="PortSharingBinding"
contract="SimpleNetTcpService.IService" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了这个问题。我刚刚从服务元素中删除了地址属性
现在
工作
正常
I found the issue. I just removed the address attribute from the service element
was
now
Works fine now