Ad
FTPClient Cannot Resolve Host Even With Internet Permission
I've added the correct permission into my AndroidManifest.XML
file to enable me connect to the internet from my app
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.my_test_app">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".LogOn"></activity>
<activity android:name=".ftpDetails"/>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
But, when trying to establish an FTP connection like so
FTPClient FtpClient = new FTPClient();
FtpClient.connect(ftpServer + ftpFolder); // THIS IS WHERE THE ERROR OCCURS
FtpClient.login(ftpUser, ftpPass);
int reply = FtpClient.getReplyCode();
The error occurs on FtpClient.connect(ftpServer + ftpFolder);
The values in the variables are in the format of
ftpServer = ftp://ftp.myServer.co.uk/mySite.co.uk/
ftpFolder = My Folder (Test)
I can get to this folder through Windows File Explorer on my PC so I know it's a valid path, but when testing in the app I get the following error
Unable to resolve host "ftp://ftp.myServer.co.uk/mySite.co.uk/My Folder": No address associated with hostname
Ad
Answer
The argument of FTPClient.connect
method (or actually the inherited SocketClient.connect
) is hostname
, not URL.
So it should be:
ftpServer = "ftp.myServer.co.uk";
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad