I was running my application fine.There were some changes in the network,like my router and internet connection got changed.Suddenly in the LogCat,I see an error like connection refused.I have provided the static IP still I get the same error.
I am running my server on my laptop and the app on the device. Intially I was able to access the application through the app and also through the browser.Can you guide me and does my Android device needs a new setting that I am missing?
Definitely, you faced some networking problem. So, the diagnostic is the same as for any connected device.
check local Android firewall - try to connect to some another server, like facebook.com or google.com
check your laptop firewall settings
draw your network schematic carefully and think what should be working and how
try tcpdump\wireshark to see what's actually going on the wire
Hope you win!
Well the static IP works not sure why it was not working before may be because I was using a LAN connection only for laptop not a same WIFI connection both for laptop and android device.
Related
Volley service is running on emulator correctly but not on real device? I have also change localhost to my IP address?
I have also tried for increasing volley request time but still not solved with this issue.
Just try to be more specific with the question.
If you are using local host
- just try to connect the phone to the computer and try to compile the app check its working or not
try to access the url from the browser check its accessible
This will run your app on device connected.
Enable USB debugging on your device by going to Settings > Developer options.
click on run and select your device.
The problem is with the URL that you are sending requests to.
If you have your device connected to your system via USB, try
http://10.0.2.2/myserverfile.php
else if your server is somewhere hosted online, use http://www.myserverlocation.blah/myserverfile.php
I have created a back end in Ruby on Rails and I am using url http://192.168.1.6:3000/products/4.json
where my phone is running with ip on the same gateway. http://192.168.1.somethign When I try connecting from android it gives the error unknown host exception. I also tried 10.0.2.2, which gives the same error. i tried running this url from the phone browser, and it says the webpage is not available. The phone is connected to the system using USB, both are in the same network using same wifi, I have also given the uses permission to access internet in the manifest file. How do I give the url now?
It is unable to resolve host, so I'm not mentioning the code, i shall add it if that helps.
After excessive searching and realizing the problem was not with the code but the reason was inability of phone and laptop to communicate properly. Still I could not fathom why? though they were in the same WiFi network. I solved my problem using this method . Putting it here for others reference,
1) Turn on the hotspot of your android phone
2) Connect your laptop to that network.(the hotspot).
3) Check the ipaddress now using ipconfig
4) Proceed using this ip address
I've setup a racoon server on my linux router. It was working ok with my xperiaz (C6603) road warrior. However after I applied the latest update to android 4.4.2 (firmware 10.5.A.0.230) it stopped working correctly. I have ping from the phone to each ip (local ip or internet) but when I use FQDN it can't be resolved. I can ping the phone from within my local network too. VPN is IPSec Xauth RSA. Checking with adb DNS server is correctly set:
getprop net.dns1
192.168.6.1
I also tried pushing the same ip as dns2 but no change. I also noticed that after closing the connection to the vpn server net.dns1 remains 192.168.6.1 however the phone is able to correctly resolve addresses. In few minutes it gets changed back to my 3g provider setting.
I tried to redirect all traffic through the tunnel via the advanced vpn setting (Forwarding routes = 0.0.0.0/0) and tried to set DNS statically via the same settings (DNS servers = 192.168.6.1). Even setting the DNS server to my provider's DNS addres didn't work which makes me think the problem is with the android itself.
DNS server is working as far as I can tell:
$ dig #192.168.6.1 dir.bg +short
194.145.63.12
Forwarding is enabled on my router so shouldn't be the problem. I've read about a bug in android but it's in android 2.x and seems to impact wifi connections.
Have you seen similar problems and as I'm not an expert with android and adb, can you tell me what commands are available in adb/shell to trace the problem? Phone is not rooted and it's not possible for the moment to root it.
UPDATE:
the tunnel is working ok when I connect via wifi hotspot. The problem appears to show only via my 3g carrier. Any ideas how to work around this?
After updating to 4.4.4 I still got the same problem. Further testing revealed that the problem is more likely to be in the Android rather than my 3g carrier. Over wifi the VPN worked flawlessly after using wifi tethering from another phone via the same provider it worked ok again so my 3g carrier isn't blocking anything.
Yesterday I finally rooted my phone and installed SDFix to restore full access to my SD card. Now VPN is working ok again even via 3g. I hope someone can confirm/reject that solution as I see no relation between vpn and sd card at all. However I experienced initially the problem with my update to 4.4.2 where Sony started to follow Google's policy about storage access.
i have in my laptop in virtualbox a UbuntuServer with a webservice at ip: 192.168.1.46, and webservice, ServerName is api.webservice, so from my laptop if i try in the browser api.webservice it works well!.
Now the problem, from the android device not work, the webservice,laptop and device are connect in the same network, from the device if i try in the browser 192.168.1.46, it tell me it works, but if i try api.webservice not work..
there are any solution?
Probably this is a problem with name resolution.
Your laptap (Windows?) is able to resolve "api.webservice", but your Android device not.
It highly depends on your infrastructure (WLAN-Router, DHCP-Server) how to solve this problem. You could perhaps provision your WLAN-Router/DHCP-Server to permanently bind api.webservice to the IP address of your Ubuntu box, so Android device can make a NS-lookup.
I suppose your Android app will connect a real Internet server in future. In this case, I wouldn't bother connecting the webservice by IP-address for test purposes.
When your app is published and used outside your local network, name resolution will work when connecting to a internet server registered in "official" DNS.
I have a Tomcat server running on Localhost. My app can access it in the emulator using 10.0.0.2:8080. But when I connect a device it can't access the server.
I've seen some similar questions but couldn't get this working. can someone give me the steps on what to do?
we use 10.0.2.2:8081 because 127.0.0.1 is reserved for the emulator, however, when you need to try the application through a real device you need to change the URL to your PC IP
go to CMD and run ipconfig, look for IPv4 address, this IP you will use it..
add it to the URL for example: http://192.somethin.somthin.somthing:8081/the-location.php
P.S: you should set your firewall off and turn off any antivirus
The device may not be on the same network as the Tomcat server. Does your network provide VPN access? If so, try installing an Android VPN client (Junos Pulse is a good free one). Connect your device to VPN and try again.
10.0.0.2 looks like an internal address. The emulator is likely able to connect because the machine on which it is running is connected to the network. The actual device needs a direct connection as well. VPN should solve that.