文章内容

2017/4/6 17:01:48,作 者: 黄兵

Cannot send command to the server because the response for previous one was not received.

今天在用VS 2013 WebExpress提交的时候出现如下错误:

Cannot send command to the server because the response for previous one was not received.

解决方法:

This exception should only be thrown after a previous FtpException (representing the actual cause of the problem) was silently ignored.

The cause of the first exception is usually a timeout while waiting for the response of a command that the client sent to the FTP server. When a timeout or similar exception occurs, the Ftp object is most likely left in an unusable state because it has not received the response it was waiting for, and any attempt to send another command would most likely result in a similar problem. Therefore, if the application tries to issue another FTP command using an Ftp object in this state, we throw the exception you are seeing.

To handle this, detect the "bad" state of the Ftp object after catching the first FtpException that caused it - simply check whether Ftp object's State property is FtpState.Ready. If it's not, re-connect and try again.

分享到:

发表评论

评论列表