I have to connect to server(servlet on tomcat) always running and process the http request and send the response..
Client is Androbile mobile application.
I aware that I can connect using HTTP Client..
But to connect from device to server running on my PC...
I want to check if I can connect to my localhost from device...
Also if I want to use mobile network to connect from any android device on which this app is deployed.... Do I have to host this website(Server)...
Please help me
You can do it if you have WiFi, simply join network and then in browser provide IP of your pc. As for wider accessibility, then yes you need to get host
Related
I want to host a server on my mobile device and send request to it from my computer. Both device are in the same network. I use flutter HttpServer.bind(InternetAddress.loopbackIPv4.host,8080); to initialize my server.
I can send requests to it by addressing localhost:8080 e.g. in my phone's browser, but I'm not able to connect to it from my pc while using my phone's local ip address that I found in wi-fi details on my phone. I can ping said address, but that's all.
Does anybody know why that happens? Am I using wrong IP, are there some android firewall settings that I don't know about or is it just impossible?
I have a web server running on a mac laptop. This laptop is connected to the network by my android smartphone (which receives the network by mobile operator). I would like to make visible my web server from outside, so I installed a port fowarding application on my smarthone and associated its port 8080 to the port of my laptop 80.
Then I found the IP address of my mobile device by the site http://whatismyipaddress.com/ and I tried to connect by using as URL mobile.ip:8080. The connaction failed. So could anybody tell me where I am wrong?
Thanks in advance for your help
I have been trying to set up an app that allows communication between two devices, a server and a client. I have established the connection and can send messages between the two as long as they are connected to the same source of internet. When I connect the devices to two different sources, I am not able to establish a connection between the two. It works by entering the IP address of the server you want to connect to.
For example, if my server device is connected to my home Wi-Fi and my client device is connected to the same Wi-Fi router, communication works as supposed to. But, when I connect the server to Wi-Fi and my client to cellular data (or different Wi-Fi router), the client is not able to find the server.
From all the searching I've done, I found that it is because my server is bound to my local host. So my question is, How can I make my server reachable from anywhere regardless of what network you are connected to?
I used this tutorial to get my server running:
http://android-er.blogspot.com/2014/02/android-sercerclient-example-server.html
The very first comment is a question that asks why it only works on a local network and someone answered saying you have to set up port forwarding on your router. From what I understand, this will work only if the server device is always connected to the same router. This will not be the case for my app. The server will have a new IP address as the device changes networks. I want this IP address to always be reachable no matter what network the server is connected to.
You will need to create a relay server. This would be set up using a java application on the PC and it would manage virtual "rooms" that then relay the messages to the clients. The computer you run your relay server off of will need port forwarding but the clients will not. Much of the code from that tutorial could be applied to this concept.
See: How to create a java Server that accepts client connections and then build a relay connection for a client pair
If your server is behind a firewall, you will not be able to reach it unless that port is open on the firewall. The only way to avoid this is to have a non-firewalled server.
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
I wrote an app to connect to java server running in PC. It works fine in emulator but its not working when i try the same from my mobile. I used the Mobiles 3G network to connect to IP address.
(Based on question comment)
I assume that your server application is running on the same machine as the android emulator. In this case the emulator can reach your server with 10.0.2.2.
If you're trying to contact your server via mobile 3G you have to use the IP of your Internet connection (What is my IP?). The request will reach your router. The router has to forward this request to your server machine. So if your server has a local IP 192.168.0.10 and it listens to port 2412 your router should forward all incoming request for this TCP port to this IP.
You should allow the 3G internet in Settings. (Emulator doesn't need this, it uses ethernet connection of your PC).
Your application should diagnose the state and possibilities of Internet connection and report it to you as a user of the debug mode. Or/and something - to the usual user.