Android - FTP problem in Android - android

I am trying to do ftp to local host. but im getting error
03-03 00:49:40.747: WARN/System.err(4151): java.net.ConnectException: /127.0.0.1:1160 - Connection refused
03-03 00:49:40.758: WARN/System.err(4151): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:255)
And the code follows like this
FTPClient ftp;
server = "10.0.2.2";
username = "newuser";
password = "wampp";
remote = "/sample.txt";
local = "/data/data/com.test.sample/files/sample/sample.txt";
ftp = new FTPClient();
InputStream input;
input = new FileInputStream(local);
ftp.storeFile(remote, input);
input.close();
I am using XAMPP server as my localhost. It Contains FileZilla. Same code works fine as normal java application.

It doesn't appear that you're actually using the server, username or password variables. Take a look at this example to get some direction:
http://hoang17.com/posts/android/android-how-to-upload-a-file-via-ftp

How is your android device connected to the network?? Can you even ping 10.0.2.2 from the device itself??
I suggest installing busybox on your android device, it has telnet and ftp commands to test your FTP server. If you cannot access your ftp from busybox/android shell, than you have firewall or port forwarding issues.

Related

sql server connection in android studio

android studio, how connect to sql server withpout a server ip sample http:\myhomepage:1433
i dont waht to connect use an ip sample:
111.111.1.111:1433
To connect to your localhost server, you should be connected to the same network (Phone and the Computer with the server), just open cmd and type ipconfig and get the ip address for the server. in your android connection string enter http://ipaddress/projectfolder
You can only connect using the domain name http://example.com for a hosted live website since mobile devices won't recognize your localhost

Using physical device with Android Studio to send data to SQL Server

I have created an Android App with the Android Studio IDE. I have done all the codes, everything seems to be ok, but I get error every time I try to send to SQL Server. I know I am very close to figuring it out, and I know it has something to do with the IP address. I have enabled all the Protocols for SQL Server.
I've disabled the Windows Firewall.
Anti-virus is not the issue.
I am very confused on which IP Address to use for communication to work properly. Both Computer and Tablet are connected to my iPhone Hotspot network.
try
{
Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
String username = "sa";
String password = "patrickdorian";
String gender = "";
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Connection DbConn = DriverManager.getConnection("jdbc:jtds:sqlserver://192.168.137.166:1433/Android DB;"+"encrypt=false;user="+username+";password"+password);
[Here][1]
Here is the error when I try to send the data to SQL Server[1]: https://i.stack.imgur.com/G3hID.jpg

How can I access my localhost from my physical Android device?

I have seen this question
I am creating a flutter app and restful API with Laravel.
it is work on AVD with url = "10.0.2.2:8000".
and my browsers on computer url = "localhost:8000".
I turned off the firewall on windows 10.
I can access to Xampp dashboard from my phone's browser "192.168.1.8:80" , but it doesn't work with port 8000
My computer Ip
Xampp server
Try this:
php artisan serve --host 0.0.0.0 --port 80
Just make sure that the port is free.
Reference: https://stackoverflow.com/a/30675683/5192105
php artisan serve --host=you ip address

Android app failed to connect to local server over WIFI

I'm developing an Android app that must connect to the server to retrieve some data. I've 2 devices connected on my local WIFI via a router: My development laptop (as server) and my development android phone (as client). The laptop has as IP address 192.168.41.50 and my Apache HTTP server is running on port 81.
My problem is the following:
If I run my android application to retrieve data into the server, it doesn't work, it's giving me a timeout exception:
D/OkHttp: <-- HTTP FAILED: java.net.SocketTimeoutException: failed to connect to /192.168.43.50 (port 81) after 120000ms
But the same address is working on the laptop's browser
How can I solve this problem.
Have a look at the firewall.
Switch it off for a test.
Your problem solution is simple ->
You have to allow external devices to connect your server.
If you are using Wamp Server then look at this post for your answer ->
How to enable local network users to access my WAMP sites?
If you are using Xampp Server then look at this post for your answer ->
Accessing localhost (xampp) from another computer over LAN network - how to?
Hope this solve your problem.

android mobile connect to sql server

I'm able to connect to local SQL server database by using Genymotion emulator. But when generate to APK and run on mobile, it doesn't connect to database. I notice the logcat shows "Connect failed: No route to host". I have turn on my wifi and the signal is very strong.
Below are methods that I have tried but still cannot solve it.
1) Turn ON/OFF wifi when run the app.
2) Set allow remote connection in SQL server.
3) Same network (Local IP= 192.168.0.110 Mobile IP: 192.168.0.114)
4) Using different port (80/1443)
My code:
con = DriverManager.getConnection("jdbc:jtds:sqlserver://192.168.0.110/app", "test", "1234");
or
con = DriverManager.getConnection("jdbc:jtds:sqlserver://192.168.0.110:1443/app", "test", "1234");
It is highly recommended not to connect to database servers from android directly. You need to have web server in between the android client and database server. Pass all your requests to the web server and make the web server in turn connect to the database.
Check this answer https://stackoverflow.com/a/12233178/3894784. It is for mysql database and almost similar to sqlserver with little changes in connection proerties.

Categories

Resources