I'm new to Android development, I'm developing FTP client application for Android.
I'm using FTP in active mode I running list command in active mode for which server has to open data port for sending list response. I'm testing my application in Eclipse emulator.
When I run list command it will give following error, failed to establish a connection.
I have some question regarding this
Can we open data port in the emulator?
if yes then it will open ports from development machine or in the emulator itself.
also kindly tell how to fix this problem any help and suggestion is greatly appreciated.
Usually android emulator has different network with its own ip address and so on. For communicating with the server, when the server connects to development pc and issue the command, you need to redirect that to the port of the emulator.
Example:
Server is connecting to emulator on port 1234
Redirect the development machine port 1234 to emulator with the following commands
in the command prompt
C:> telnet localhost
Ex: telnet localhost 5554
(Will be logged in to the emulator)
->redir add <tcp/udp>:hostport:emulatorport
Ex: redir add udp:1234:1234
->quit
For Ref: https://developer.android.com/studio/run/emulator-networking
Regards,
SSuman185
Related
Can someone help me we have a mobile app for our capstone project i ask my friend to make it(I don't have knowledge for android developing) but i'm the one who make for our web app.he added a variable to enter hostname .the problem is my friend test it it connected using ip/CapstoneFiles ->(Foldername codeigniter). but when i try it it won't connect using IP/CapstoneFiles. i already disable my firewall and antivirus.. My pc is connected to Prepaid wifi via wired connection and i connect my phone via wifi
if you are using windows you can get IP by command ipconfig and for linux it's ifconfig
Change the IP wherever used in the project with current IP you're getting by command.
Your PC and Phone should be connected to the same network.
See if you are running it at //localhost:8080 port then use URL = "http://10.0.2.2:8080/" in your android app to access the server as this translates to localhost for the application
As you must know your application has its own pid and ports within so you will be required to use this
let me know if unclear
I have a rails server running on my machine. I am running the server using the following command:
rails s -b my_computer_ip
Now, I am trying to access the server on my phone's browser using the following command
http://my_computer_ip:3000
but I keep getting: "The site cannot be reached"
Both my phone and computer are connected over the same network.
I have tried following options:
rails s -b 0.0.0.0 (On computer)
http://192.168.1.80:3000 (On phone)
But do not work.
Earlier I used to connect to server on my phone in the same way I have mentioned but I don't understand what issue is now cropping up.
PS: When I do the following:
http://my_computer_ip
on my phone's browser, I get the page saying Apache server is running.
This is a networking concept error. You have to enable the port 3000 in your router. Instead, try running the server on port 80, your firewall is probably blocking port 3000.
I am trying to connect my phone (android) to my local server (apache) running on Ubuntu. What I did is that I typed ifconfig in a terminal, got the local IP address of my computer and typed it on my phone's navigator. Unfortunatly my phone seems to find my server but is not able to connect to it, and times out. I have tried to disable my firewall but it didn't work either.
Do you have any idea why? How can I get my phone to connect my apache server?
Thanks in advance.
You have the ip address of your server but are you using the correct port to connect to it from your phone? Your apache server may not be setup to host on the default 80 port (check the httpd.conf file).
Also - Don't disable your firewall but you can open the port your server is hosting on (maybe port 80 by default ?). You can also use Wireshark or some packet capturing software to see if the request is making it to your server and how your server is replying.
i have made an app to share your monitor to your android device by wifi, it works very well.
So i wanted to put as an option to share by usb.
I have found in many websites, the adb tcp connection.
If someone could explain me.
How i can implement such thing.
What i tried so far was:
adb forward tcp:port tcp:port
adb connect ip
No sucess.
Make your app run a server. Run the server on some port e.g. port no. 5749. Send the data thru the server then do adb forward tcp:5749 tcp:5749 and abd connect phoneIP
By the help of these website, I understood how to Connect Tcp via Usb without using Wifi.
So what i wasn't understanding was:
º1 to connect via adb, the android device can only be the server. (otherwise it wasn't working.)
º2 you are going to connect to the localhost (i will explain it better after.) so no need of any wifi ip.
So what i did was:
1º Android: start the server to listen to any connection at PORT (Connect by Usb)
2º PC: use adb, something like:
"shell adb.exe forward tcp:PORT tcp:PORT"
3º PC: try to connect to the server of your android device by the ip which is now "localhost" and your PORT
Then in the code i just redirected the client of the computer as an android device, and handled the server as a normal socket. (Kinda hard to explain myself.)
I am new to android and backend development and came in a problem today. I have setup rails server on my computer and localhost:3000 shows ruby page. My android device (connected by usb) main activity has a webview and I tried localhost:3000
Use Your IP Address Instead of Localhost
Instructions if you're on a Mac. Other OS's, do something comparable.
Connect your computer and Android tablet to the same Wifi connection.
Open System Preferences.
Go to the Network section.
Click on your Wifi connection and copy your IP address from that window:
Make sure your Rails server is running on port 3000.
On your tablet, point to your computer IP address with port 3000,
192.168.0.14:3000
Hope that helps!
/ JP
Just simple, you should try to do these steps same as below:
First, you type this command in order to show your ip address: ifconfig
Second, in your console, type this command: rails s -b your_ip_address
For example: rails s -b 192.168.1.102
Finally, open browser on your android and type: 192.168.1.102:3000
You can read this rails official to understand clearly.
http://edgeguides.rubyonrails.org/4_2_release_notes.html#default-host-for-rails-server
http://smyck.net/2007/03/11/how-to-bind-webrick-to-any-ip-address/
You need to bind your webrick to ip address of your ethernet or wifi adapter.
if your laptop and device are on the same wifi, just connect to the hostname or IP of your laptop http://[laptop Ip or hostname]:3000