wcf - HTTP 无法注册 URL ... 因为 TCP 端口 ... 正在被另一个应用程序使用

标签 wcf http wcf-binding

首先,我不擅长WCF。 我在 WindowsService 中托管了一个 WCF 服务。 由于有时服务因异常而停止运行:

HTTP 无法注册 URL http://+:8092/MyService/因为 TCP 端口 8092 正在被另一个应用程序使用。

  • 没有任何东西使用这个端口,它对我尝试过的任何端口都是一样的。
  • 已配置 SSL 证书。

有很多机器可以启动这个服务,但是最需要的(客户的)机器不能。 我在本网站或其他任何地方看到很多帖子,但找不到解决方案。 我从来没有看到过像“它帮助了我”这样的帖子。 我已经卡住了好几天了,请帮忙。

配置文件中的数据下方:

<system.serviceModel>
    <services>
      <service name="MyCompany.MyApp.MyAppService" behaviorConfiguration="MetadataSupport">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8092/MyAppService" />
            <add baseAddress="net.tcp://localhost:8093/MyAppService" />
            <add baseAddress="net.pipe://localhost/" />
          </baseAddresses>
        </host>
        <endpoint binding="wsDualHttpBinding" contract="MyCompany.MyApp.IMyAppService" />
        <endpoint binding="netTcpBinding" contract="MyCompany.MyApp.IMyAppService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <endpoint address="tcpmex" binding="mexTcpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MetadataSupport">
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True" httpGetUrl="" />
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug httpHelpPageEnabled="True" includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

最佳答案

您正在通过 wsDualHttpBinding 使用 WCF 双工通信。在这种情况下,WCF 在端口 8092 上创建一个 HTTP 套接字来为客户端回调 提供服务。显然客户端与 IIS 5.X 冲突。 (我猜你有 XP 和 IIS 5.x)

要解决此问题,您必须在客户端的绑定(bind)配置中提供一个 clientBaseAddress 并指定一个不同的端口。

示例客户端配置: Client configuration snippet

我希望这确实是您机器的问题,请将此解决方案的结果通知我。

祝你好运:-)

关于wcf - HTTP 无法注册 URL ... 因为 TCP 端口 ... 正在被另一个应用程序使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7572305/

相关文章:

wcf - 通过 WCF 路由服务将调用路由到旧版 ASMX Web 服务

asp.net - 如何在 ASP.NET 和 WCF 之间对用户进行身份验证?

http - 从主域到语言的重定向应该是永久性的吗?

javascript - Linux Ajax (mootools Request.JSON) header 错误

c# - WCF:缓存 SSL 数据

c# - 是否存在用于生成 WCF 服务以为 self 跟踪实体提供获取和保存的 T4 模板?

c# - 是否可以获取从 http 响应(包括 header )收到的总字节数?

java - 是否有全面的 Java Metro 和 WCF 互操作性网站、技术或资源?

c# - 网络 TCP 绑定(bind) : The URI prefix is not recognized

WCF 服务,请求或增加 Binding 上的 SendTimeout 值