Results 1 to 6 of 6

Thread: QFtp disconnected from server

  1. #1
    Join Date
    Jul 2008
    Location
    Philippines
    Posts
    60
    Thanks
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QFtp disconnected from server

    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..

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QFtp disconnected from server

    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2008
    Location
    Philippines
    Posts
    60
    Thanks
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFtp disconnected from server

    hi, thnks for the reply..
    anyway, heres my code in connecting to the ftp server:

    Qt Code:
    1. void ftpagentclass::ftpPutConnectToFtp()
    2. {
    3. ftpPut = new QFtp();
    4. connect(ftpPut, SIGNAL(stateChanged(int)), this, SLOT(ftpPutStateChanged(int)));
    5.  
    6. ftpPut->connectToHost(sample.ftp.server,21);
    7. ftpPut->login(USERNAME, PASSWORD );
    8. ftpPut->setTransferMode(QFtp::Passive);
    9. }
    To copy to clipboard, switch view to plain text mode 

    in my ftpPutStateChanged(int):

    Qt Code:
    1. void ftpagentclass::ftpPutStateChanged(int state)
    2. {
    3. switch(state){
    4. case QFtp::Unconnected:
    5. qDebug() << "FTP PUT: Unconnected!";
    6. if(LOGIN)
    7. logToMonitor("Disconnected from server!", "red");
    8. else
    9. logToMonitor("Can't connect to server.", "red");
    10.  
    11. logToMonitor("Reconnecting...", "yellow");
    12. LOGIN = false;
    13. ftpPutConnectToFtp(); //reconnect to server if disconnected
    14. break;
    15. case QFtp::HostLookup:
    16. qDebug() << "FTP PUT: Host Lookup";
    17. logToMonitor("Looking for server " + SERVER, "yellow");
    18. LOGIN = false;
    19. break;
    20. case QFtp::Connecting:
    21. qDebug() << "FTP PUT: Connecting";
    22. logToMonitor("Connecting...", "yellow");
    23. LOGIN = false;
    24. break;
    25. case QFtp::Connected:
    26. qDebug() << "FTP PUT: Connected";
    27. logToMonitor("Connection established!", "green");
    28. logToMonitor("Logging in...", "green");
    29. LOGIN = false;
    30. break;
    31. case QFtp::LoggedIn:
    32. qDebug() << "FTP PUT: LoggedIn";
    33. logToMonitor("Logged In successful!", "green");
    34. LOGIN = true;
    35. break;
    36. case QFtp::Closing:
    37. qDebug() << "FTP PUT: Closing";
    38. LOGIN = false;
    39. break;
    40. default:
    41. qDebug() << "FTP PUT: Unknown error!";
    42. logToMonitor("Unknown error occured!", "red");
    43. LOGIN = false;
    44. break;
    45. }
    46. }
    To copy to clipboard, switch view to plain text mode 

    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

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QFtp disconnected from server

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jul 2008
    Location
    Philippines
    Posts
    60
    Thanks
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFtp disconnected from server

    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..

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QFtp disconnected from server

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    cutie.monkey (22nd May 2009)

Similar Threads

  1. Replies: 3
    Last Post: 29th November 2009, 20:24
  2. How to ping a server ?
    By Nyphel in forum Newbie
    Replies: 2
    Last Post: 23rd April 2007, 11:27
  3. cannot connect to X server
    By jcr in forum Qt Programming
    Replies: 1
    Last Post: 18th April 2007, 14:22
  4. How a server can write "Hello" to a browser ?
    By probine in forum Qt Programming
    Replies: 2
    Last Post: 1st December 2006, 14:43
  5. synching client readings to server output
    By OnionRingOfDoom in forum Qt Programming
    Replies: 14
    Last Post: 28th January 2006, 18:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.