【问题标题】:net.tcp hosted in IIS7.5 on windows 7 virtual machine using .NET 4.0net.tcp 托管在使用 .NET 4.0 的 Windows 7 虚拟机上的 IIS7.5 中
【发布时间】:2011-02-21 17:29:56
【问题描述】:

我有最简单的 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>

【问题讨论】:

  • 您的网站在 IIS 中有哪些绑定? (不是 WCF 绑定)

标签: wcf iis net.tcp


【解决方案1】:

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

<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" />

现在可以正常使用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-09-20
    • 2016-10-04
    • 2021-06-20
    • 2017-07-26
    • 2011-02-22
    • 2011-07-21
    • 2015-01-10
    • 1970-01-01
    相关资源
    最近更新 更多