When reading your question, I was suspicious that this was due to (or could be fixed) setting KeepAlive to false . Looking at SO - this question refers to the same issue and points to this: fooobar.com/questions/962217 / ...
Try to install:
request.KeepAlive = false;
With KeepAlive set to false , your connection will be closed at the end of each request . If you transfer a large number of files, this can be a problem, as it takes time to retransmit credentials, etc. The positive thing is to recreate the connection in a known / initial state, which should solve your problem (even if this is not the root cause).
To find out what happens if you can enable verbose logging on your server, you should see the last command issued before you see this error. This should give you a better idea of ββwhat is going on. Found this thread saying almost the same thing.
Update:
If I read the bottom of the link that I wrote myself, I could respond even better, the command that was probably reissued is part of the login process (i.e. USER username ), and this is your likely problem:
The reason the scade is no longer valid is because WebRequest uses a lease that expires after a certain time. Unless you explicitly create an instance of the lease and specify its timeouts, FtpWebRequest appears to use the default timeout values. I believe what happens when the lease expires, FtpWebRequest will then try logging in again.
So, look here with the correct search:
suggests that the expected query is not infinite by default, as specified , but actually 10000 ms . Which seems like a pretty big discrepancy. So you can also try installing:
request.Timeout = -1;
And see if your bug fixes.
Don't really think that this could be your problem, so move it to the bottom:
Also, make sure your request.ReadWriteTimeout is suitable for the speed you see for a larger file. The default is 5 minutes , which would be quite a long time for 290k, so I expect this to not be the source of your error. Also, I would expect a closed connection error if this was a problem.