Android app can`t connect to LAN server - android

I am building android app that connects to tcp server via socket.
When I run the server (java server) on Windows, the app connect, send, receive etc. just fine, but when I run the server (same code) on linux (OpenSuse 13.2 kde desktop) The app can connect only on emulator. If I run it on my LG Magna it does not connect. I am using every internet permission I could find.

You have to chceck if you can ping both devices. You have to get ip from android and from your serwer try to ping one from other. To android you can connect threw adb. But it will be ok if you will ping Android from Linux. I am quite shure that you wont be able.

You can try to connect to your server by putty/telnet - even from your serwer to check if your socket is opened. If you wont't be able to open port maybe you have any info/warning/eroor when you are creating socket on serwer. If no what is the message when you are connecting maybe there is something wrong.

Related

Not able to access rails server from phone

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.

Connect Android phone to local server

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.

How can I connect an android client to my XMPP (ejabberd) server, hosted on my local machine (Windows based OS)?

I want to test my ejabberd (xmpp) server, which I've hosted on my laptop, which is working on windows 10 based OS. I want to connect my android client to this server. So I went on to the internet, and found some solutions. But they seem don't work for me. This is what I've tried:
1.) Create a hotspot on a phone. Don't use data/wifi connection, as server is already on the machine.
2.) Connect the laptop to the hotspot.
3.) On cmd (running as admin), type 'ipconfig', after starting xmpp server (Obviously).
4.) Copy IPv4 address (External IP), and access web panel on the mobile browser through it.
So, I hurried toward my phone, and typed
http://[IPv4 Address]:[port open on the server for incoming connection/5280]/admin
But it(browser) throws 'Can't reach the webpage' error.
When I run
http://localhost:5280/admin
on my laptop, I could easily access my web portal, but It's unreachable on my android phone. What can I do now?
Well I solved this problem by accessing IPv4 of my laptop through my wifi router, and connecting to the port of my server through it. Initially, my browser (both of my laptop and my phone) weren't able to reach the server's port. But I later figured out it was problem in my .yml configuration file. Server wasn't set to listen all the IPv4 calls, instead it was listening to all IPv6. So I changed this, and it then become accessible to all devices on the same wifi. So it was my bad idea to connect it through the hotspot :P

Mobile device can't connect to web server in my computer

I'm developing an android application that connects to a web server to get info. I'm using HTTP Client library to connect with the web server.
I've two scenarios:
Emulator and the web server both of them installed in the same PC. The application works perfect.
Android mobile (Xperia P) connected with my PC via USB cable, and the web server installed in my PC.
In the second scenario, the application can't connect with the web server.
If I have 3G disabled, an "network unreachable" error message is received.
If I have 3G enabled, an "java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)" error message is received.
So, I would like to test my application in a real device, and the application needs to connect with the web server that is installed in my PC.
How could I do visible the web server to the android devive? I would like to have the mobile devive in the network of my PC.
Thanks
Try the following. Make sure that the phone's wifi is turned on and the phone is connected to the same network as your development machine.
Now, instead of "localhost" or "127.0.0.1" use the I.P Address of machine (assigned by DHCP for example) while calling the webservice.
Hope this helps.
Best Regards,
Anay

Ports in emulator

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

Categories

Resources