FTP monitoring and uploading new files
I have a FTP monitoring / download application using C # sockets. I got this error message:
421 Disconnected from you because you have been inactive for 300 seconds.
Anyone have an explanation? I have done a search on this subject, but still I cannot find a good explanation. Thanks.
a source to share
It says that it disconnected you because your connection was inactive for 300 seconds. This is a common practice on FTP servers because (unlike HTTP) FTP is not stateless, connections remain open, and connections that do nothing can easily fill the server's connection limit.
The obvious solution is that you won't be dormant for 300 seconds. Create a timer that does something every minute or so, like getting a list of files in the current directory or something.
EDIT: As mentioned in ChaosPandion's comment, perhaps you just need to close the connection when you're done and reopen it when you need it.
a source to share
I think this pretty much explains it myself. The server disconnects your connection as it has been inactive for 5 minutes. Questions: what counts as an activity? I am afraid the answer will not be found in the FTP RFC as it may be implementation specific. In addition, the timeout interval is variable (it can be configured using the FTP administration utility).
If I'm right, you just need to develop your application to handle this limitation by reconnecting on disconnect and doing whatever is necessary to re-check the internal state of your application.
a source to share