FTP File Download under Android 6

Several of my apps download a file via FTP for game use. This worked fine under Droid versions below 6, but are failing using droid 6. Any ideas?

Thanks,

Carey

Are there any errors in your console log?

Well, adb is next… But any ideas? The same apps work under 5 but not six. Nothing has changed, but the download or ftp process. Just looking for clues. Thanks

    Error 229: Extended Passive Mode Entered

Again, this is only under Android 6. No issue on older Droid devices. I’m using the Graham Ransom FTP code.

Thanks

Android 6 brought a bunch of permission related changes.  Entering passive mode shouldn’t generate an error. In general, FTP uses two channels to communicate: a command channel that you open to the server, then when you request to transfer a file, the FTP server opens up a channel back to you to do the transfer. However, firewalls block that type of activity. This is where “passive” mode comes in. With Passive mode, the transfer communications should take place over the command channel or another channel opened from the client to the server.

So it’s possible that Android 6 permissions changed enough to block FTP. However since you’re using something built by a 3rd party, we can’t really answer how it works. I’d reach out to Graham and see what he has to say.

Rob

Rob,

Graham’ stuff is not a product, it’s just a function (which was very useful as there were no examples of FTP for corona)

Any idea why this would generate a 229 error.

local ftp = require(“socket.ftp”)

local ltn12 = require(“ltn12”)

function newConnection(params)

        

        local self = {}

        self.host = params.host or “anonymous.org

        self.user = params.user or “anonymous”

        self.password = params.password or “”

        self.port = params.port or 21

        local putFile = function(params, command)

                        

                success, error = ftp.put{

                        host = self.host, 

                        user = self.user,

                        password = self.password,

                        port = self.port,

                        type = “i”,

                        step = ltn12.all,

                        command = command,

                        argument = params.remoteFile,

                        source = ltn12.source.file( io.open( params.localFile, “rb” ) )  

                }

                

                if success then

                        if params.onSuccess then

                                params.onSuccess( { path = self.host … params.remoteFile } )

                        end

                else

                        if params.onError then

                                params.onError( { error = error } ) 

                        end

                end

                                

                return success, error

                

        end

        

        local getFile = function(params)

        

                local success, error = ftp.get{

                        host = self.host, 

                        user = self.user,

                        password = self.password,

                        port = self.port,

                        type = “i”,

                        step = ltn12.all,

                        command = command,

                        argument = params.remoteFile,

                        sink = ltn12.sink.file(params.localFile)

                }

                

                if success then

                        if params.onSuccess then

                                params.onSuccess( { path = params.localPath } )

                        end

                else

                        if params.onError then

                                params.onError( { error = error } ) 

                        end

                end

                        

                return success, error

        end

        function self:upload(params)

                return putFile(params, “stor”)

        end

        

        function self:download(params)

                

                params.localPath = system.pathForFile( params.localFile, system.DocumentsDirectory )

                params.localFile = io.open( params.localPath, “w+b” ) 

                return getFile(params)

        

        end

        

        function self:append(params)

                return putFile(params, “appe”)

        end

        

        return self

        

end

Can I see the invocation of where you’re calling the FTP functions?

Can you drop back to build 2879 and try that? 2883 we updated the socket library. We need to make sure this isn’t a regression bug.

Also, FTP message 229 is not an error condition. Its in the category of: The requested action has been successfully completed.

As I said above, passive mode is a common way of working with FTP when behind a firewall. It’s possible Andorid 6 isn’t allowing arbitrary connections back to the device in which case switching to passive mode is required to transfer the files.

Rob

Rob,

My original files were over 1 year ago. I originally spotted this issue under 2874.

The FTP file is working again under 2909.

Thanks,

Carey

Are there any errors in your console log?

Well, adb is next… But any ideas? The same apps work under 5 but not six. Nothing has changed, but the download or ftp process. Just looking for clues. Thanks

    Error 229: Extended Passive Mode Entered

Again, this is only under Android 6. No issue on older Droid devices. I’m using the Graham Ransom FTP code.

Thanks

Android 6 brought a bunch of permission related changes.  Entering passive mode shouldn’t generate an error. In general, FTP uses two channels to communicate: a command channel that you open to the server, then when you request to transfer a file, the FTP server opens up a channel back to you to do the transfer. However, firewalls block that type of activity. This is where “passive” mode comes in. With Passive mode, the transfer communications should take place over the command channel or another channel opened from the client to the server.

So it’s possible that Android 6 permissions changed enough to block FTP. However since you’re using something built by a 3rd party, we can’t really answer how it works. I’d reach out to Graham and see what he has to say.

Rob

Rob,

Graham’ stuff is not a product, it’s just a function (which was very useful as there were no examples of FTP for corona)

Any idea why this would generate a 229 error.

local ftp = require(“socket.ftp”)

local ltn12 = require(“ltn12”)

function newConnection(params)

        

        local self = {}

        self.host = params.host or “anonymous.org

        self.user = params.user or “anonymous”

        self.password = params.password or “”

        self.port = params.port or 21

        local putFile = function(params, command)

                        

                success, error = ftp.put{

                        host = self.host, 

                        user = self.user,

                        password = self.password,

                        port = self.port,

                        type = “i”,

                        step = ltn12.all,

                        command = command,

                        argument = params.remoteFile,

                        source = ltn12.source.file( io.open( params.localFile, “rb” ) )  

                }

                

                if success then

                        if params.onSuccess then

                                params.onSuccess( { path = self.host … params.remoteFile } )

                        end

                else

                        if params.onError then

                                params.onError( { error = error } ) 

                        end

                end

                                

                return success, error

                

        end

        

        local getFile = function(params)

        

                local success, error = ftp.get{

                        host = self.host, 

                        user = self.user,

                        password = self.password,

                        port = self.port,

                        type = “i”,

                        step = ltn12.all,

                        command = command,

                        argument = params.remoteFile,

                        sink = ltn12.sink.file(params.localFile)

                }

                

                if success then

                        if params.onSuccess then

                                params.onSuccess( { path = params.localPath } )

                        end

                else

                        if params.onError then

                                params.onError( { error = error } ) 

                        end

                end

                        

                return success, error

        end

        function self:upload(params)

                return putFile(params, “stor”)

        end

        

        function self:download(params)

                

                params.localPath = system.pathForFile( params.localFile, system.DocumentsDirectory )

                params.localFile = io.open( params.localPath, “w+b” ) 

                return getFile(params)

        

        end

        

        function self:append(params)

                return putFile(params, “appe”)

        end

        

        return self

        

end

Can I see the invocation of where you’re calling the FTP functions?

Can you drop back to build 2879 and try that? 2883 we updated the socket library. We need to make sure this isn’t a regression bug.

Also, FTP message 229 is not an error condition. Its in the category of: The requested action has been successfully completed.

As I said above, passive mode is a common way of working with FTP when behind a firewall. It’s possible Andorid 6 isn’t allowing arbitrary connections back to the device in which case switching to passive mode is required to transfer the files.

Rob

Rob,

My original files were over 1 year ago. I originally spotted this issue under 2874.

The FTP file is working again under 2909.

Thanks,

Carey