Reputation: 1
I've created a wcf service which is working properly with small data. (My current MaxReceivedMessageSize is 10485760). When I send some huge data (say x bytes)which exceeds 10485760 Client is getting below error.
The maximum message size quota for incoming messages (10485760) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.
I know this can be fixed by increasing MaxReceivedMessageSize value. But the tricky thing here is when I keep MaxReceivedMessageSize to 10485760 and send response of size 2x bytes, Instead of getting above error client is getting timeout error after timeout value specified time in config file.
Debugging on server side provided below error
The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue.
Because of this client is not able to know what went wrong and could not understand how to fix it.
My Question is, in both the cases I'm sending data more than MaxReceivedMessageSize But the error is different. Why? Why can't the client simply receive "The maximum message size quota has been exceeded" error instead of socket getting closed?
I want client to receive the error and correct the MaxReceivedMessageSize value instead of socket getting closed and client getting timed out
Thanks!
Upvotes: 0
Views: 349
Reputation: 4215
Service bus buffers(streamlines the data between client and server) require interactions with raw WCF messages.
public sealed class MessageBufferClient
{
public void Send(Message message);
public void Send(Message message,TimeSpan timeout);
public Message Retrieve();
public Message Retrieve(TimeSpan timeout);
}
Both methods are subject to a timeout, which defaults to one minute for the parameterless versions.
For the sender, the timeout specifies how long to wait if the buffer is full. For the retriever, the timeout specifies how long to wait if the buffer is empty.
Hence for x bytes the Retrieve method is called which has waited for default 1 minute between which anything might have happended like shaky connection/connection lost or buffer full(if its full ,next time it is not used). So the safe assumption is some failure in the connection.
Upvotes: 0