0
votes

I am sending large file stream from client to wcf service using tranfer mode as stream with basichttpbinding.

During streaming, if the client loses the network connection , client gets socket timeout exception. But WCF service continues to wait for the stream until the timeout specified. When the network resumes and next call is made to wcf service from the client, we observe that wcf has not released the previous process and still waiting for the previous response.

Timeouts specified in client and wcf service is as below

opentimeout, closetimeout, sendtimeout, receivetimeout is set to 12 hours.

The file is not released upto 12 hours. Is there any method where we while during reading the stream from wcf, if client is disconnected, terminate the process. I have been struggling from the past 2 days. Please help

1

1 Answers

0
votes

Even microsoft advice to use chunking instead of streaming for very large content. Especially when the communication channel is not reliable enaugh chunking could be the best choice.

Try to use some contract like this:

    [ServiceContract]
    public interface IFileWriter
    {
        [OperationContract]
        void Open(string file);

        [OperationContract(IsOneWay = true)]
        void Write(byte[] buffer);

        [OperationContract]
        void Close();
    }

For more information see Large Data and Streaming chapter Large Data Content

Fully implemented example here.

Or just google for "WCF streaming vs chunking".

P.S. Chunking has several other advantages -