我正在建立FTP连接以在iOS和Android上传文件。
使用wifi可以正常工作,但是通过数据连接(3g或4g),应用程序无法正常工作,没有任何反应。
这是我的代码:http://programantios.blogspot.com.es/2015/11/titanium-subir-ficheros-ftp-desde.html
使用wifi,日志就是这个(带有我在数据连接停止时输入的注释):
-- 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
答案 0 :(得分:0)
某些3G / 4G网络不支持FTP主动模式,只支持被动模式。
我打赌这是出于技术原因,但我没有确认。
尝试使用被动模式配置FTP站点,然后重试。
此致