0

我有最简单的 WCF 服务,它在使用 basicHttp 绑定托管在 IIS 中时工作。它有一个名为 DoNothing 的空方法,它不接受任何参数并返回一个 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>
4

1 回答 1

0

我发现了这个问题。我刚刚从服务元素中删除了地址属性是

<service name="SimpleNetTcpService.Service">
        <endpoint address="net.tcp://192.168.0.2:12345/SimpleNetTcpService/Service"
          binding="netTcpBinding" bindingConfiguration="PortSharingBinding" 
          contract="SimpleNetTcpService.IService" />

现在

<service name="SimpleNetTcpService.Service">
        <endpoint 
          binding="netTcpBinding" bindingConfiguration="PortSharingBinding" 
          contract="SimpleNetTcpService.IService" />

现在工作正常

于 2011-02-21T18:10:11.090 回答