Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing a FileStream to WCF throws "Timeouts are not supported on this stream" exception

Tags:

wcf

filestream

When trying to pass a small FileStream to my WCF service I get "Timeouts are not supported on this stream" error. Can anyone see what I'm doing wrong?

Interface:

[OperationContract]
List<SystemClass> ReadExcelFile(System.IO.FileStream stream);

Web.Config

<bindings>
  <basicHttpBinding>
    <binding name="streaming" maxReceivedMessageSize="2147483647" transferMode="Streamed">
    </binding>
  </basicHttpBinding>
</bindings>

<services>
  <service name="MISDashboard.wcfService" behaviorConfiguration="">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="streaming" contract="MISDashboard.wcfService"></endpoint>
  </service>
</services>
...
<httpRuntime maxRequestLength="2147483647"/>
like image 386
ijason03 Avatar asked Jul 02 '13 21:07

ijason03


1 Answers

Do not use FileStream as parameter but Stream. A FileStream is a stream bound to the local file system; once you start transferring the data, in the other side the stream will be coming from the network, so a FileStream can't be used there.

You could believe it's pretty the same but Stream is treated in a special way by WCF and by-pass many internal tasks.

Also, for sending Large Data consider reading this great article.

like image 196
Cybermaxs Avatar answered Oct 14 '22 22:10

Cybermaxs