hi all,..
i have a small FTP program which is based from FTP example.. now, what i encountered is that every 5 mins, my FTP program is disconnected from the server.. I tried this with 2 different FTP server and the same problem occurs..
Printable View
hi all,..
i have a small FTP program which is based from FTP example.. now, what i encountered is that every 5 mins, my FTP program is disconnected from the server.. I tried this with 2 different FTP server and the same problem occurs..
The servers probably have timeouts set for 5 minutes... Can you be more specific about what happens? Did you try connecting using a commandline ftp client and wait 5 minutes to see what happens?
hi, thnks for the reply..
anyway, heres my code in connecting to the ftp server:
Code:
void ftpagentclass::ftpPutConnectToFtp() { connect(ftpPut, SIGNAL(stateChanged(int)), this, SLOT(ftpPutStateChanged(int))); ftpPut->connectToHost(sample.ftp.server,21); ftpPut->login(USERNAME, PASSWORD ); }
in my ftpPutStateChanged(int):
Code:
void ftpagentclass::ftpPutStateChanged(int state) { switch(state){ qDebug() << "FTP PUT: Unconnected!"; if(LOGIN) logToMonitor("Disconnected from server!", "red"); else logToMonitor("Can't connect to server.", "red"); logToMonitor("Reconnecting...", "yellow"); LOGIN = false; ftpPutConnectToFtp(); //reconnect to server if disconnected break; qDebug() << "FTP PUT: Host Lookup"; logToMonitor("Looking for server " + SERVER, "yellow"); LOGIN = false; break; qDebug() << "FTP PUT: Connecting"; logToMonitor("Connecting...", "yellow"); LOGIN = false; break; qDebug() << "FTP PUT: Connected"; logToMonitor("Connection established!", "green"); logToMonitor("Logging in...", "green"); LOGIN = false; break; qDebug() << "FTP PUT: LoggedIn"; logToMonitor("Logged In successful!", "green"); LOGIN = true; break; qDebug() << "FTP PUT: Closing"; LOGIN = false; break; default: qDebug() << "FTP PUT: Unknown error!"; logToMonitor("Unknown error occured!", "red"); LOGIN = false; break; } }
Now, what i encountered is that when my program is connected to ftp server, after 5 mins, it will be disconnected, so i have to reconnect it again.. i didn't add any timeout... do i miss something in my code? thnks
Please do as I said - connect to the same server with telnet to the ftp port (and/or a commandline ftp client) and see if you also get disconnected after 5 minutes.
hi!..
i do what you have instructed me, that is connecting to the ftp server through command prompt in windows, and i experienced the same problem.. it is also disconnected after 5 mins.. what do you think the cause of this problem? again thnks..
The server disconnects you after 5 minutes of inactivity. That's perfectly normal. If you want to prevent that, you can issue some command to the server from time to time (such as pwd) to keep the connection alive.