Friday, May 8, 2015

Transferring Large Amounts of Data with WCF

I found myself wanting to send the contents of a fairly large file (specifically a ~100MB MSI installer) via WCF. However, the call to the method of which the byte array was a parameter always failed with a TimeoutException, but thrown almost immediately, much quicker than the one minute it allegedly waited.

The problem was not a timeout but WCF's on-by-default DoS protection. I'm very concerned about security for this application, but the large data transfer was from the server to client, never the other way around. So, it's alright for the server to be able to flood the client with data, because clients are voluntarily connecting to the server.

The fix is to increase the ListenBacklog and/or MaxBufferSize on the NetTcpBinding. (They may also apply to some of the other bindings.) That allows larger amounts of data to be received in one shot.

No comments:

Post a Comment