i'm trying to connect to the server from my android device in order to get XML inputStream to do that i'm using XmlPullParser
my server Url is:
http://www.biat.com.tn
so, when i'm trying to get the inputstream from this url, I'm getting an unknown host Exception, the screen become black... (although it works for me in localhost)
Then, to check my config I tried to ping the server from the ADB shell, but there is no connection established !!!
I check an other server (http://www.topnet.tn), but i faced the same problem.
PS : I'm getting Streams from these URLs in Navigator
I think that .TN (Tunisia) domain name are not known by Android devices !!!!
i googled this problem and I found a solution, that i should lauch my application in -dns-server mode with putting 8.8.8.8 as dns server... so it works
but pinging my URL server does not !!! please any one can understand this problem !!!
please help...
How are you loading the data? URLConnection, HttpClient?
http://www.biat.com.tn does http 302 redirect to http://www.biat.com.tn/biat/.
In most cases you will need to handle redirect in your code.
Related
I am getting the error "It is impossible to create a new session because 'createSession' which takes HttpClient, InputStream and long was not found or it is not accessible"
also my Appium server gets killed autometically after this error in console.
Please help to resolve.
The error may occurs from various reason. You need to check your appium server log to know the exact cause. Beside that you can verify following.
Start your appium server in session-override option.
Make sure your appium server is running.
Make sure your are using correct url of appium server.
Confirm your device is properly connecting to the laptop. You can verify it by using adb devices command (for android). Make sure it is showing only one device.
Make sure your DesiredCapabilities are correct or all required desired capabilities are included.
Try re-starting the appium server.
While trying to connect to the localhost, an error is showing. Please find the error below
BasicNetwork.performRequest: Unexpected response code 404 for http://10.10.14.120:8080/rest/ws/profile_request
Please check the connection like http://10.10.14.120:8080/rest/, if get anything displays on the page your connection is good. then the problem is with your parameters
some time due to anti virus and firewall can causes this problem. So disable your anti virus and firewall it can solve your problem.
Also make sure http://10.10.14.120:8080/rest/ is working in your mobile browser as well
I saw a tutorial and It was fine until the guy did some wierd thing I couldn't find a way to do it to get my project running.
he could type 10.0.2.2 in the url bar of emulator and get to localhost page of wampserver
so I tried it but at first I had permission denied error and I fixed it, now when I type http://10.0.2.2 I get "Not Found The requested URL / was not found on this server".
thanks for your help !
UPDATE: Even when I try 127.0.0.1 in my computer it gives the same error
PS : http://10.0.2.2 is not a private adress, it stands for localhost in android emulator. in fact it gives me wampserver error so it's accessing localhost, I just need to get rid of the error.
Thank you all !
If you want localhost, write http://localhost or http://127.0.0.1 into your webbrowser.
As #vcsjones pointed out in comments, the address you're talking about might be a private IP of his workstation.
On executing the following statement the app does not respond for a minute and then following logcat message occurs :
HttpPost httpPost = new HttpPost("http://10.0.2.2:8080/webapp/CreateUser");
logcat -
org.apache.http.conn.HttpHostConnectException: Connection to http://10.0.2.2:8080 refused
PS - i've tried using "ip address" , 127.0.0.1 AND localhost instead of 10.0.2.2 still the same case.
Also the permissions for INTERNET and ACCESS_NETWORK_STATE are also in the manifest file.
Your server code mostly will be accessible on the local and Wifi network if you have turned on sharing and network discovery on your system.
For the physical device to see this server it has to be on the same network. Also you need to use the IP address of your server.
Okay , the problem has been solved .
As answered by both Codemon and Jayesh , in order to use real device to run the app from Android Studio , you have to use the ip address of the server in place of 10.0.2.2 and make sure your phone device and server are in the same network:-
HttpPost httpPost = new HttpPost("http://192.168.1.53:8080/webapp/CreateUser");
I guess my internet connection was not stable , so ip was changing and thats why it didn't work before.
Thanks for your help guys.
I am having trouble sending a message to a device through the company proxy.
I have done the GCM tutorial on the google site and have successfully registered a device on the google servers with the android emulator,
and also on the server at my end.
For this I had to go through the company proxy, setting it in the access point of the emulator.
Now the problem I have is sending a message from my server to the device through the same proxy.
I am using the servlet code from the demo which uses the
com.google.android.gcm.server.Sender
helper class to send the message.
I am running the servlets on tomcat 7.
I have tried setting the proxy up in the catalina.properties file like so.
http.proxyHost=proxy.company.com
http.proxyPort=8080
And I have tried setting properties inside the servlet itself like below.
System.setProperty("http.proxyHost", "proxy.company.com");
System.setProperty("http.proxyPort", "8080");
But still I get the timeout.
I know its the company proxy because I got the messaging working at home where I have no proxy.
I have seen a proxy object created in the java code and then a connection created with it, but I dont think that is usable here since I am using Sender helper class to send the message.
This is the line that fails in a timeout.
Result result = sender.send(message, registrationId, 5);
Any help would be appreciated.
Regards
Bill
Alright, I finally have it working. In my comment I mentioned that I had succeeded in sending out the message, but the emulator was not recieving it. I had forgotten to follow my own earlier advice and run the emulator from the command line with the proxy parameters set like so:
emulator.exe -avd avd22google -http-proxy proxy.company.com:8080 -debug-proxy
So to summarise, my initial problem was that I had registered the emulator on the with GCM and with my local server, but the when I clicked send message I was getting a timeout.
I initially thought it was the firewall so I did some research and set up the proxy in tomcats catalina.properties file.
This made no difference.
I used the "Charles" web proxy debugger software to see where the message was attempting to be sent to and it came up with https://android.googleapis.com:443
So I initially I added the following to my catalina.properties file:
https.proxyHost=proxy.company.com
https.proxyPort=443
It still did not work. A colleague of mine told me that our company proxy handles all types of requests through port 8080, so I changed the the poort line to:
https.proxyPort=8080
This allowed the message to be sent out.
But then the message was not getting through to the emulator and I was receiving the following error in LogCat.
[GTalkConnection.12] doConnect: caught XMPPError connecting to mtalk.google.com:5228.: -- caused by: java.net.SocketException: The operation timed out
Then I remembered that you need to start the emulator with the command line to get it to use the proxy. Once I did this a flood of messages appeared on my emulator!
So I finally have it working end to end. It's taken me about a week to get GCM fully working within my company firewall, so hopefully this post can help some other poor sod doing this in the future.
cheers
Bill