gpt4 book ai didi

c# - 使用 TCP : "The message could not be dispatched..." 时收到错误

转载 作者:可可西里 更新时间:2023-11-01 02:41:49 25 4
gpt4 key购买 nike

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

There was a communication problem. The message could not be dispatched because the service at the endpoint address 'net:tcp://elec:9090/CoordinateIdTool_Tcp/IdToolService.svc is unavailable for the protocol of the address.

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

最佳答案

我想我的问题和你的类似。我做了什么,我去了 WCF 网络服务的站点,而不是应用程序池,进入高级设置,从启用的协议(protocol)中删除了 net.tcp,点击确定,保存了设置,称为 net.tcp 服务,它当然给了我股票异常(exception)...

 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 重新添加到启用的协议(protocol)中。然后网络服务运行得非常好。我不确定为什么会这样。我认为它强制重置了 TCP 监听器。不过我不能确定。

关于c# - 使用 TCP : "The message could not be dispatched..." 时收到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5463850/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com