gpt4 book ai didi

c# - 服务器未提供有意义的回复,这可能是由于契约(Contract)不匹配、 session 过早关闭或内部服务器错误造成的

转载 作者:行者123 更新时间:2023-11-30 13:04:15 24 4
gpt4 key购买 nike

我有一个客户端/服务器应用程序,我正在尝试使用我创建的 WCF 服务,但它一直抛出异常,我没能弄清楚!!

这是 WCF 服务器的代码:

<configuration>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<services>
<service name="ChatService.ChatService"
behaviorConfiguration="behaviorConfig">

<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:7997/Host/"/>
<add baseAddress="http://localhost:7998/Host/"/>
</baseAddresses>
</host>
<endpoint address="tcp"
binding="netTcpBinding"
bindingConfiguration="tcpBinding"
contract="ChatService.IChat"/>

<endpoint address="net.tcp://localhost:7996/Host/mex"
binding="mexTcpBinding"
contract="IMetadataExchange"/>
</service>
</services>
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior name="behaviorConfig">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="100"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="tcpBinding"
maxBufferSize="67108864"
maxReceivedMessageSize="67108864"
maxBufferPoolSize="67108864"
transferMode="Buffered"
closeTimeout="00:00:10"
openTimeout="00:00:10"
receiveTimeout="00:20:00"
sendTimeout="00:01:00"
maxConnections="100">
<security mode="None">
</security>
<readerQuotas maxArrayLength="67108864"
maxBytesPerRead="67108864"
maxStringContentLength="67108864"/>
<reliableSession enabled="true" inactivityTimeout="00:20:00"/>
</binding>
</netTcpBinding>
</bindings>

</system.serviceModel>
</configuration>

这是客户端的 WCF 服务:

<configuration>
<connectionStrings>
<add name="IClient.Properties.Settings.Co_WorkersDataBaseConnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Co-WorkersDataBase.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IChat" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"
transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="67108864" maxBufferSize="67108864" maxConnections="100"
maxReceivedMessageSize="67108864">
<readerQuotas maxDepth="32" maxStringContentLength="67108864" maxArrayLength="67108864"
maxBytesPerRead="67108864" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="20:00:10"
enabled="true" />
<security mode="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:7997/Host/tcp" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IChat" contract="CHATSERVICE.IChat"
name="NetTcpBinding_IChat" />
</client>
</system.serviceModel>
</configuration>

我想做的是与服务器建立连接,但我得到的只是这个异常!!

The Server did not provide a meaningful reply , this might be caused by a contract mismatch, a premature session shutdown or an internal server error

Server stack trace: 
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeEndService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IClient.CHATSERVICE.IChat.EndConnect(IAsyncResult result)
at IClient.CHATSERVICE.ChatClient.EndConnect(IAsyncResult result) in C:\Users\Desktop\IClient\Service References\CHATSERVICE\Reference.cs:line 641
at IClient.CHATSERVICE.ChatClient.OnEndConnect(IAsyncResult result) in C:\Users\Desktop\IClient\Service References\CHATSERVICE\Reference.cs:line 652
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)

PS:当我点击客户端应用程序的连接按钮时,我得到了这个异常,服务器与客户端应用程序同时运行。

请帮忙!!

最佳答案

服务器上没有安全性,但客户端上的客户端凭据类型窗口具有消息安全性 - 这些需要匹配。

关于c# - 服务器未提供有意义的回复,这可能是由于契约(Contract)不匹配、 session 过早关闭或内部服务器错误造成的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9910365/

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