Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: FTP Status 1002  (Read 11532 times)

0 Members and 2 Guests are viewing this topic.

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
FTP Status 1002
« on: January 03, 2015, 10:42:46 pm »
Hello

I get a status 1002 when trying my application.
It says it means 'ConnectionClosed', what is the difference with that regarding 'ConnectionFailed'?

And, what exactly does it means? And, how to fix it?
I've already called ftp.keepAlive() before the login() function, but that didn't worked.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: FTP Status 1002
« Reply #1 on: January 03, 2015, 11:03:38 pm »
This is purely a question about the FTP protocol.  Unless you have some reason to believe SFML is the root cause of the problem, you would probably be better off googling "FTP 1002".

For example, https://stackoverflow.com/questions/26647423/nsurlerrordomain-error-code-1002-description and http://dev.error1002.com/faq_connect.php#1002 suggest that a bad URL is one possible cause.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: FTP Status 1002
« Reply #2 on: January 03, 2015, 11:36:03 pm »
FTP codes >= 1000 are specific to SFML, the FTP RFC only defines codes up to 5xx (similarly to HTTP, the major digit is the status "category").

So no, this is not purely a FTP issue, and no, Googling for error 1002 in this case would not help much ;)
Laurent Gomila - SFML developer

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: FTP Status 1002
« Reply #3 on: January 03, 2015, 11:45:35 pm »
Oh...well, I guess it would be nice if the tutorial or documentation mentioned this somewhere.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: FTP Status 1002
« Reply #4 on: January 03, 2015, 11:56:04 pm »
Laurent Gomila - SFML developer

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: FTP Status 1002
« Reply #5 on: January 04, 2015, 11:30:55 am »
Okay, connection with server closed. So, that means that it suddenly closed? But I used 'keepAlive()'.
Could it also mean the specified server doesn't exist?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: FTP Status 1002
« Reply #6 on: January 04, 2015, 12:14:15 pm »
Quote
Could it also mean the specified server doesn't exist?
No, you would get a ConnectionFailed error in this case. ConnectionClosed means that you were connected to the server, but the connection suddenly broke.

Quote
But I used 'keepAlive()'.
How do you use it?
Laurent Gomila - SFML developer

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: FTP Status 1002
« Reply #7 on: January 04, 2015, 12:57:52 pm »
Here is another code example where it also doesn't work:

#include <iostream>
#include <string>

#include <SFML/Network.hpp>

using namespace std;
int main() {
sf::Ftp ftp;
sf::Ftp::Response response;
string server, username, password;
int port;


cin >> server;
cin >> port;

ftp.connect(server, port);
ftp.keepAlive();

cin >> username;
cin >> password;

response = ftp.login(username, password);

if (response.isOk()) {
        cout<< "Ok" <<endl;
} else if (!response.isOk()) {
        cout << "Not ok; Status " << response.getStatus() <<endl;
} else {
        cout<< "Error" <<endl;
}
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: FTP Status 1002
« Reply #8 on: January 04, 2015, 01:57:16 pm »
keepAlive() must be called periodically, what it does is only to send a no-op to the server to signal that you're still there.

Does it work if you hard-code the login and password, so that there's no delay between the commands?
Laurent Gomila - SFML developer

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: FTP Status 1002
« Reply #9 on: January 04, 2015, 06:11:41 pm »
^No,

#include <iostream>
#include <string>

#include <SFML/Network.hpp>

using namespace std;
int main() {
sf::Ftp ftp;
sf::Ftp::Response response;
/*string server, username, password;
int port;


cin >> server;
cin >> port;
*/

ftp.connect("ftp://server.cf");
/*
cin >> username;
cin >> password;
*/

response = ftp.login("myUser", "MyPass");

if (response.isOk()) {
        cout<< "Ok" <<endl;
} else if (!response.isOk()) {
        cout << "Not ok; Status " << response.getStatus() <<endl;
} else {
        cout<< "Error" <<endl;
}
}
 

FTP through browser with exact same authentication does work though.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: FTP Status 1002
« Reply #10 on: January 04, 2015, 07:23:10 pm »
Can you print the body and status of the response to the connect call?
Laurent Gomila - SFML developer

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: FTP Status 1002
« Reply #11 on: January 04, 2015, 07:34:11 pm »
If it was me debugging this I'd start by fireing up Wireshark and capture a working session from a commandline ftp client and then a trace with my application and then compare what happens on the wire in the two cases.

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: FTP Status 1002
« Reply #12 on: January 04, 2015, 07:54:53 pm »
It says that status is 1002, and getBody isn't a function of sf::Ftp::Response.
I think getBody() is for HTTP.

What weird is, I tried filtering port 21 in Wireshark but it captured nothing when I ran my application. I closed my browser and tried that application as well; in Linux' process manager network also was 0 (didn't react).

So my application actually isn't sending a request...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: FTP Status 1002
« Reply #13 on: January 04, 2015, 08:33:12 pm »
Quote
It says that status is 1002
So it's happening on connect(), not on login()?

Quote
getBody isn't a function of sf::Ftp::Response.
I think getBody() is for HTTP.
Well, the content of the response (getMessage).
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
AW: Re: FTP Status 1002
« Reply #14 on: January 04, 2015, 08:38:47 pm »
What weird is, I tried filtering port 21 in Wireshark but it captured nothing when I ran my application. I closed my browser and tried that application as well; in Linux' process manager network also was 0 (didn't react).

So my application actually isn't sending a request...
Do you use a local FTP server?
Did you pick the correct interface?
What if you just use "ftp" as filter?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything