简体   繁体   中英

FTP Connection - Sockets in 3g or 4g, in wifi works okey

I'm doing a FTP connection to upload files in iOS and Android.

With wifi all works fine and faster, but with data connection (3g or 4g) the app doesn't work, nothing happens.

This is my code: http://programantios.blogspot.com.es/2015/11/titanium-subir-ficheros-ftp-desde.html

With wifi, the log is this (with a comment I put when the data connection stops):

-- FTP UploadFileFtp: 1450270757920.mp4 | ftp.e.es | 21
[DEBUG] : Socket opened!
[DEBUG] : Received: 220 FTP Server ready.
[DEBUG] :
[DEBUG] : --- Code: 220
[DEBUG] : Successfully wrote to socket.
[DEBUG] : Received: 331 Password required for temporal
[DEBUG] :
[DEBUG] : --- Code: 331
[DEBUG] : Successfully wrote to socket.
[DEBUG] : Received: 230 User temporal logged in
[DEBUG] :
[INFO] : FTP: Log in successful
[DEBUG] : --- Code: 230
[DEBUG] : Successfully wrote to socket. //--> DATA NETWORK FINISH HERE
[DEBUG] : Received: 250 CWD command successful
[DEBUG] :
[INFO] : FTP: Changed active directory to /
[DEBUG] : --- Code: 250
[DEBUG] : Successfully wrote to socket.
[DEBUG] : Received: 227 Entering Passive Mode (10,1,125,78,54,68).
[DEBUG] :
[DEBUG] : --- PASSIVE MODE
[DEBUG] : IP & Port: 10,1,125,78,54,68
[DEBUG] : port info: 13892
[DEBUG] : isUpload: true
[DEBUG] : *******createNewSocket: 13892 | ftp.e.es
[DEBUG] : --- Code: 227
[DEBUG] : Socket <{"port":13892}> connected to host <ftp.e.es>
[INFO] : callback after setting TYPE I ...
[INFO] : {
[INFO] : bytesProcessed = 7;
[INFO] : code = 0;
[INFO] : errorDescription = "";
[INFO] : errorState = 0;
[INFO] : source = "[object TiNetworkSocketTCP]";
[INFO] : success = 1;
[INFO] : type = write;
[INFO] : }
[INFO] : send STOR 1450270757920.mp4 to control socket...
[DEBUG] : Sending stor request...STOR /1450270757920.mp4
[DEBUG] :
[DEBUG] : Successfully wrote to socket.
[DEBUG] : Received: 200 Type set to I
[DEBUG] :
[DEBUG] : --- Code: 200
[DEBUG] : Received: 150 Opening BINARY mode data connection for /1450270757920.mp4
[DEBUG] :
[INFO] : DATA connection initiated on control socket!... writing file contents to socket_data
[INFO] : WRITE FILE to socket now ..
[INFO] : Packet send. NaN% 0 / 1120409 bytes wroted
[DEBUG] : --- Code: 150
[INFO] : Packet send. NaN% 10240 / 1120409 bytes wroted
[INFO] : .......
[DEBUG] : Packet send. NaN% 1120409 / 1120409 bytes wroted
[DEBUG] : File upload. 1120409 bytes wroted
[DEBUG] : Success: true
[DEBUG] : Received: 226 Transfer complete
[DEBUG] :
[DEBUG] : --- Code: 226
[DEBUG] : --- close

Some 3G / 4G networks don't support FTP Active Mode but only passive mode.

I bet this is for technical reasons but I have not the confirmation.

Try to configure your FTP site with passive mode and try again.

Regards

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM