Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FTPFileProvider.isReachable returns false with errors even though I can read file contents on FTP server. #56

Closed
gsrinivas37 opened this issue Aug 1, 2017 · 11 comments
Labels

Comments

@gsrinivas37
Copy link

gsrinivas37 commented Aug 1, 2017

I'm trying to use FTPFileProvider with latest iOS public beta and XCode public beta. I am able to read contents of files on FTP server but when I call some of the methods like isRechable(), recursiveList(), attributesOfItem() then it doesn't seem to work and also I get some errors.

Here is the simple piece of code I've written in viewDidLoad()

    let credential = URLCredential(user: "seenu", password: "mypassword", persistence: .permanent)
    let ftpProvider = FTPFileProvider(baseURL: URL(string: "ftp://192.168.0.3:21")!, credential: credential)
    ftpProvider?.delegate = self as FileProviderDelegate
    ftpProvider?.contents(path: "HD/Photos/test.jpg", completionHandler: { (data, error) in
        DispatchQueue.main.async {
            self.image.image = UIImage(data: data!)
            print("Image has been read using ftpProvider")
        }
    })
    
    ftpProvider?.isReachable(completionHandler: {bool in
        print("ftp is rechable: \(bool)");
    })
    
    ftpProvider?.recursiveList(path: "HD/Photos", useMLST: false, completionHandler: {
        contents, error in
        for file in contents {
            print("Name: \(file.name)")
            print("Size: \(file.size)")
            print("Creation Date: \(file.creationDate)")
            print("Modification Date: \(file.modifiedDate)")
        }
    })
    
    ftpProvider?.attributesOfItem(path: "HD/Photos/test.jpg", completionHandler: {
        attributes, error in
        if let attributes = attributes {
            print("File Size: \(attributes.size)")
            print("Creation Date: \(attributes.creationDate)")
            print("Modification Date: \(attributes.modifiedDate)")
            print("Is Read Only: \(attributes.isReadOnly)")
        }
    })
    
    ftpProvider?.contents(path: "HD/test.txt", completionHandler: {
        contents, error in
        if let contents = contents {
            print("File content is: \(String(data: contents, encoding: .utf8))") // "hello world!"
        }
    })

Reading the test.jpg and test.txt file works fine but the other calls doesn't given any output. Below is the console output.

2017-08-01 00:18:29.450605-0400 ftp[1183:64255] [] nw_connection_fillout_tcp_statistics 1 Connection is not ready
2017-08-01 00:18:29.450846-0400 ftp[1183:64255] [] tcp_connection_get_statistics Failed to get statistics from connection
2017-08-01 00:18:29.456293-0400 ftp[1183:64255] [] nw_connection_fillout_tcp_statistics 2 Connection is not ready
2017-08-01 00:18:29.456840-0400 ftp[1183:64255] [] tcp_connection_get_statistics Failed to get statistics from connection
2017-08-01 00:18:29.460717-0400 ftp[1183:64255] [] nw_connection_fillout_tcp_statistics 3 Connection is not ready
2017-08-01 00:18:29.461325-0400 ftp[1183:64255] [] tcp_connection_get_statistics Failed to get statistics from connection
ftp is rechable: false
2017-08-01 00:18:29.490551-0400 ftp[1183:64272] TIC TCP Conn Missing Error [3:0x60400016f600]: Generating 1:54
2017-08-01 00:18:29.490794-0400 ftp[1183:64272] TIC Read Status [3:0x60400016f600]: 1:57
Image has been read using ftpProvider
File content is: Optional("Hello world !!")
2017-08-01 00:20:29.543466-0400 ftp[1183:81206] TIC TCP Conn Missing Error [1:0x60000016e1c0]: Generating 1:54
2017-08-01 00:20:29.544054-0400 ftp[1183:81206] TIC TCP Conn Missing Error [2:0x60000016e4c0]: Generating 1:54

Let me know if I'm doing something wrong or is it some genuine problem ?

@amosavian amosavian added the bug label Aug 4, 2017
@amosavian
Copy link
Owner

Maybe something changed in new platform in [NS]URLSessionStreamTask. I shall check in Xcode 9.0 soon.

@karthikvt
Copy link

I'm facing same problem. @gsrinivas37 did you fixed it ? Any luck?

@amosavian
Copy link
Owner

@karthikvt @gsrinivas37 does the problem still exist with latest version?

@amosavian
Copy link
Owner

Closed due to inactivity. I believe it has been address as my tests are passing. You can open it if the problem still exists.

@Double-Dude
Copy link

Hi @amosavian , I still have the problem, could you please help?
`
let url = URL(string: "ftp://192.168.0.174")
let credential = URLCredential(user: "123", password: "123", persistence: .none)

    fileProvider = FTPFileProvider(baseURL: url!, passive: true, credential: credential)
    fileProvider!.contentsOfDirectory(path: "/", completionHandler: {
        contents, error in
        for file in contents {
            print("Name: \(file.name)")
            print("Size: \(file.size)")
            print("Creation Date: \(file.creationDate)")
            print("Modification Date: \(file.modifiedDate)")
        }
    })

`

Error:

2018-03-16 12:03:34.168227+1300 FTPTestApp[11408:714824] [] nw_connection_fillout_tcp_statistics 1 Connection is not ready
2018-03-16 12:03:34.168363+1300 FTPTestApp[11408:714824] [] tcp_connection_get_statistics Failed to get statistics from connection
2018-03-16 12:03:41.873278+1300 FTPTestApp[11408:714843] TIC TCP Conn Missing Error [1:0x60c0001624c0]: Generating 1:54

@amosavian amosavian reopened this Mar 16, 2018
@amosavian
Copy link
Owner

@quhaoran007 do have any problem with isReachable() method?

@Double-Dude
Copy link

@amosavian Thanks for the reply. I will try in a moment and let you know

@Double-Dude
Copy link

@amosavian Tried 2 FTP servers, both not working. And I tried Gold Raccoon lib, that worked, just to test the servers.

The code and logs are pasted in the following:

`
let url = URL(string: "ftp://192.168.1.254")
let credential = URLCredential(user: "user", password: "pass", persistence: .none)

    fileProvider = FTPFileProvider(baseURL: url!, passive: true, credential: credential)
    fileProvider.isReachable { (reachable) in
        debugPrint("Reachable:\(reachable)")
    }

`

Logs:

2018-03-17 19:43:39.558232+1300 FTPTestApp[13702:779448] [] nw_connection_fillout_tcp_statistics 1 Connection is not ready
2018-03-17 19:43:39.558328+1300 FTPTestApp[13702:779448] [] tcp_connection_get_statistics Failed to get statistics from connection
"Reachable:false"
2018-03-17 19:43:42.536894+1300 FTPTestApp[13702:782004] TIC Read Status [2:0x600000172000]: 1:54
"Reachable:false"
2018-03-17 19:43:48.168490+1300 FTPTestApp[13702:782004] TIC TCP Conn Missing Error [2:0x600000172000]: Generating 1:54
2018-03-17 19:44:39.908879+1300 FTPTestApp[13702:782823] TIC TCP Conn Missing Error [1:0x604000172600]: Generating 1:54

@amosavian
Copy link
Owner

Can you read file contents or list directories?

@Double-Dude
Copy link

Hi @amosavian , can you please give me some demo code? I was wondering whether it's because I've done it incorrectly. Because all the commands I used have failed. Same logs.

@Nathipha
Copy link

Nathipha commented May 16, 2019

@amosavian
I'm using the latest version of your library (with Swift 5, Xcode 10) and have just run into the same problem:

ftpProvider?.isReachable(completionHandler: { (success, error) in
    print("Success: \(success), Error: \(error)")
    if success {
        //Continue
    } else {
        //Show error message
    }
})

always fails with the error:

Success: false, Error: Optional(Error Domain=NSURLErrorDomain Code=-1011 "(null)" UserInfo={NSErrorFailingURLKey=ftp://10.1.1.15:16/, NSURL=ftp://10.1.1.15:16/, NSErrorFailingURLStringKey=ftp://10.1.1.15:16/})

error!.localizedDescription gives some more information:

Success: false, Error: The operation couldn’t be completed. (NSURLErrorDomain error -1011.)

If I ignore "success", I can:

  • log into the ftp server
  • list files with ".contentsOfDirectory()"
  • read files with ".contents()"
  • download files with ".copyItem()"

just fine and there are no more error messages (still dealing with everything being done twice but that's are different problem).

Why is it throwing an error message, even though login seems to work just fine?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants