【问题标题】:Error received when using TCP: "The message could not be dispatched..."使用 TCP 时收到错误:“无法发送消息...”
【发布时间】:2013-10-01 04:59:51
【问题描述】:

我是创建 WCF 服务的新手。我在 IIS 7 上运行的 VS2008 中创建了 WCF Web 服务。当我使用 http 时,该服务运行良好。当我为 TCP 配置服务并运行时,我收到以下错误消息。

通信出现问题。这 无法发送消息 因为端点的服务 地址 'net:tcp://elec:9090/CoordinateIdTool_Tcp/IdToolService.svc 不可用的协议 地址。

我已经搜索了很多论坛,包括这个论坛,以寻求解决方案,但没有任何效果。 IIS 7 上的一切似乎都已正确设置。 WAS 已设置为运行。默认网站有一个 net.tcp 绑定,应用程序在启用的协议下有 net.tcp。

我将我认为是宿主项目中 web.config 的重要部分以及我用来测试服务的客户端项目中的 app.config 包括在内。希望有人能发现我的错误。提前感谢任何人提供的任何帮助或建议。

Web.Config

<bindings>
   <wsHttpBinding>
      <binding name="wsHttpBindingNoMsgs">
         <security mode="None" />
       </binding>
   </wsHttpBinding>
</bindings>
<services>
   <service behaviorConfiguration="CogIDServiceHost.ServiceBehavior"
           name="CogIDServiceLibrary.CogIdService">
      <endpoint address="" 
                binding="wsHttpBinding" 
                bindingConfiguration="wsHttpBindingNoMsgs"
                contract="CogIDServiceLibrary.CogIdTool">
         <identity>
            <dns value="localhost" />
         </identity>
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
                contract="IMetadataExchange" />
      <endpoint name="CoordinateIdService_TCP"
          address="net.tcp://elec:9090/CoordinateIdTool_Tcp/IdToolService.svc"
          binding="netTcpBinding" bindingConfiguration="" 
          contract="CogIDServiceLibrary.CogIdTool">
         <identity>
            <dns value="localhost" />
         </identity>
      </endpoint>
    </service>
 </services>
 <behaviors>
    <serviceBehaviors>
       <behavior name="CogIDServiceHost.ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
       </behavior>
    </serviceBehaviors>
 </behaviors>

App.Config

<system.serviceModel>
    <diagnostics performanceCounters="Off">
        <messageLogging logEntireMessage="true" logMalformedMessages="false"
            logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="false" />
    </diagnostics>
    <behaviors />
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_CogIdTool" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="None">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true"
                        establishSecurityContext="true" />
                </security>
            </binding>
            <binding name="wsHttpBindingNoMsg">
                <security mode="None">
                    <transport clientCredentialType="Windows" />
                    <message clientCredentialType="Windows" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://sdet/CogId_WCF/IdToolService.svc" binding="wsHttpBinding"
            bindingConfiguration="wsHttpBindingNoMsg" contract="CogIdServiceReference.CogIdTool"
            name="IISHostWsHttpBinding">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
        <endpoint address="http://localhost:1890/IdToolService.svc" binding="wsHttpBinding"
            bindingConfiguration="WSHttpBinding_CogIdTool" contract="CogIdServiceReference.CogIdTool"
            name="WSHttpBinding_CogIdTool">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
        <endpoint address="http://elec/CoordinateIdTool/IdToolService.svc"
            binding="wsHttpBinding" bindingConfiguration="wsHttpBindingNoMsg"
            contract="CogIdServiceReference.CogIdTool" name="IIS7HostWsHttpBinding_Elec">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
      <endpoint address="net.tcp://elec:9090/CoordinateIdTool_Tcp/IdToolService.svc"
          binding="netTcpBinding" bindingConfiguration="" contract="CogIdServiceReference.CogIdTool"
            name="IIS7HostTcpBinding_Elec" >
        <identity>
          <dns value="localhost"/>
        </identity>
      </endpoint>
    </client>
</system.serviceModel>

【问题讨论】:

    标签: c# wcf tcp


    【解决方案1】:

    我认为我的问题与您的问题相似。我做了什么,我去了 WCF Web 服务的站点,而不是应用程序池,进入高级设置,从启用的协议中删除了 net.tcp,点击确定,保存了设置,称为 net.tcp 服务,它当然给了我股票例外......

     Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http]. 
    

    然后我将 net.tcp 重新添加到启用的协议中。然后,Web 服务运行得非常好。 我不确定为什么会这样。我认为它强制重置 TCP 侦听器。不过我不能确定。

    【讨论】:

    • 我也遇到过类似的情况,在添加 net.tcp 条目后,我不得不循环应用程序池以使其正常运行。
    • 感谢 DmainEvent,这真的很有帮助。太奇怪了。
    【解决方案2】:

    【讨论】:

    • 我试过那个线程,但它没有用。现在我收到错误消息“无法激活请求的服务 net.tcp//elec:9090/CoordinateIdTool_Tcp/IdToolService.svc。”
    猜你喜欢
    • 2012-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-15
    • 2014-11-20
    • 1970-01-01
    相关资源
    最近更新 更多