Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

wcf

client

I have a Client/Server Application and i'm trying to use the WCF Service that i have created but it's keeping throwing exception and i didn't managed to figure it out !!

this is the code of the WCF Server:

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

and this is the WCF Service of the Client :

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

What I'm trying to do is to make the connection with the server but all i get is this exceptions !!

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: I get this exception when i click on the Connect Button of the Client Application, the Server is running simultaneously with the client application.

Help Please !!

like image 985
NoobMaster69 Avatar asked Nov 14 '22 08:11

NoobMaster69


1 Answers

Security is none on the server but there is message security with client credential type windows on client - these need to match.

like image 189
Chris Avatar answered Nov 16 '22 02:11

Chris