WCF "More data was expected, but EOF was reached." exception at client side, but the request hit in server side

ramnivas t 1 Reputation point
2022-06-24T09:18:46.813+00:00

I am seeing the logs which has the below exception at client side while calling WCF service (NetTcpBinding) in server side. But the crucial part is even the client facing the exception in their application but the request was successfully hit the WCF server.

Message: More data was expected, but EOF was reached.

Message: Error while reading message framing format at position 1 of stream (state: Start)
Stack Trace:
at System.ServiceModel.Channels.ClientDuplexConnectionReader.EnsureDecoderAtEof()
at System.ServiceModel.Channels.SessionConnectionReader.Receive(TimeSpan timeout)
at System.ServiceModel.Channels.SynchronizedMessageSource.Receive(TimeSpan timeout)
at System.ServiceModel.Channels.TransportDuplexSessionChannel.Receive(TimeSpan timeout)
at System.ServiceModel.Channels.TransportDuplexSessionChannel.TryReceive(TimeSpan timeout, Message& message)
at System.ServiceModel.Dispatcher.DuplexChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown

I suspect it may be occurred due to below reasons, since i could not see the data that was sent to the WCF service due to some security issue.
Scenarios:

  1. The data that was sent to the WCF service might have EOF character.
  2. The data size that was sent to the WCF service would be larger than the size that was configured (maxReceivedMessageSize) in the WCF configuration at client side.

I was trying to reproduce the scenario in my local machine, i am unable to reproduce it.
For the first scenario, i included the EOF byte (0x1A) in the payload data to sent to WCF service. but it does not throw any exception at client side.
for the second scenario, i configured the maxReceivedMessageSize value less than the payload data size, it throws the exception, but it was different exception.

What could be the reason for this exception?
How to reproduce this exception in my local?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,799 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ramnivas t 1 Reputation point
    2022-09-26T11:26:52.68+00:00

    Hi Lan,

    Thanks for the information you have shared. As you said in first reply, the issue is because of load balancer timeout configuration.

    We faced EOF exception at client side, when the processing time in WCF service reached the time that load balancer configured for timeout.

    Thanks & Regards,
    Ram Nivas T

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.