Android アプリを filezilla ftp サーバーに接続する際に問題が発生しています。サーバーは機能していますが、それでも LogCat で次の出力が得られます。
05-30 19:49:43.872: D/$$$$$$$$$$$$$$$$$$(1693): $$$$$$$$$$$$$$$$$$$$$$$$$ ERROR 1
05-30 19:50:04.913: W/System.err(1693): java.net.SocketTimeoutException: Connection timed out
05-30 19:50:04.913: W/System.err(1693): at org.apache.harmony.luni.platform.OSNetworkSystem.connect(Native Method)
05-30 19:50:04.913: W/System.err(1693): at dalvik.system.BlockGuard$WrappedNetworkSystem.connect(BlockGuard.java:357)
05-30 19:50:04.913: W/System.err(1693): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:204)
05-30 19:50:04.913: W/System.err(1693): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:437)
05-30 19:50:04.913: W/System.err(1693): at java.net.Socket.connect(Socket.java:1002)
05-30 19:50:04.913: W/System.err(1693): at org.apache.commons.net.SocketClient.connect(SocketClient.java:175)
05-30 19:50:04.913: W/System.err(1693): at org.apache.commons.net.SocketClient.connect(SocketClient.java:196)
05-30 19:50:04.913: W/System.err(1693): at org.apache.commons.net.SocketClient.connect(SocketClient.java:289)
05-30 19:50:04.913: W/System.err(1693): at General.FTPHandle.Connect(FTPHandle.java:40)
05-30 19:50:04.913: W/System.err(1693): at General.FTPHandle.doInBackground(FTPHandle.java:30)
05-30 19:50:04.913: W/System.err(1693): at General.FTPHandle.doInBackground(FTPHandle.java:1)
05-30 19:50:04.913: W/System.err(1693): at android.os.AsyncTask$2.call(AsyncTask.java:185)
05-30 19:50:04.913: W/System.err(1693): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
05-30 19:50:04.913: W/System.err(1693): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
05-30 19:50:04.913: W/System.err(1693): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
05-30 19:50:04.933: W/System.err(1693): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
05-30 19:50:04.933: W/System.err(1693): at java.lang.Thread.run(Thread.java:1019)
コードは次のとおりです。
public class FTPHandle extends AsyncTask<String, String, String>
{
public FTPClient client = null;
public FileInputStream fis = null;
private File root;
private File dir;
public FTPHandle()
{
client = new FTPClient();
fis = null;
root = android.os.Environment.getExternalStorageDirectory();
dir = new File (root.getAbsolutePath()+ "/TrackingData"); //creates directory
execute();
}
protected String doInBackground(String... arg0) {
Connect();
return null;
}
public int Connect()
{
int status = 0;
try {
Log.d("$$$$$$$$$$$$$$$$$$","$$$$$$$$$$$$$$$$$$$$$$$$$ ERROR 1");
client.connect("192.168.1.64");
Log.d("$$$$$$$$$$$$$$$$$$","$$$$$$$$$$$$$$$$$$$$$$$$$ ERROR 2");
// Create an InputStream of the file to be uploaded
fis = new FileInputStream(dir);
// Store file to server
client.storeFile(dir.getName(), fis);
client.logout();
status = 1;
} catch (IOException e) {
e.printStackTrace();
status = 0;
} finally {
try {
if (fis != null) {
fis.close();
}
client.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
return status;
}
}
Ps: サーバーは機能しています。私はそれをテストしました;)
敬具