Error: ConnectFailure (No route to host) - android

Context: I have a Xamarin.Android app that it connects to an WebAPI for different information.
Issue: When trying to access the server I get the following error:
System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error: ConnectFailure (No route to host)
Issue context: we have 2 servers in the same network, configured the same (at least we hope so, is at client site) and if we use the same app (same build) we can connect to server A, but get the mentioned error when connecting to B. About the B server: I can access from device browser the http://address/help or /token page, I can also do the desired request from 'REST Api Client' from Google Play and get a successful response. The only problem it seems when connecting from our app to the server B. This issue is also not present on our environments (as I mentioned, the A and B are at client site).
Question: What would be the problem and where should we look further?
Thank you!

I found this answer on Xamarin forms, this didn't solve my problem, but maybe it could help in yours. https://forums.xamarin.com/discussion/70731/connection-error-no-route-to-host-only-happens-on-android
I had this problem because I didn't dispose my HttpClient object. It didn't happen with the first or second request, however from request 10 it would start giving me problems. Especially when they were happening asynchronously.
I don't know if this will solve your problem, as both these seem to be a special case instance. Maybe yours is a special case as well.

Check the mobile device can able to access the API server first. Is completely related network issue. Might be your mobile app and web server used different LAN connections or WIFI networks.

I had same issue, fixed it by enabling fast deployment:
In solution explorer, right click on 'yourproject.Android' -> 'Properties' -> 'Android Options' -> check 'Use Fast Deployment'
In my case, the problem occured only when running the application through the Visual Studio 'Run' button (I used a physical device to debug on).

Related

Connection Error when starting selendroid server

I am trying to run android hybrid app tests with selendroid standalone server. When I start the server it successfully starts but I get the following error for the emulators. -
WARNING: Could not get avdName for device emulator-5672
io.selendroid.standalone.exceptions.AndroidDeviceException:
Cannot establish a connection to device.
at io.selendroid.standalone.android.TelnetClient.<init>(TelnetClient.java:40)
Can anyone help with this ?
I haven't used Selendroid before, but it seems to be that your emulator is not properly recognized or you given it a bad name. According to:
http://selendroid.io/setup.html
Please follows your steps:
You can check that the application(s) and the devices are recognized by opening a browser and navigating to: http://localhost:4444/wd/hub/status.
Check if emulator-5672 has specific name and use it on run.
Also read patiently above tutorial and check on its GitHub page if there isn't any simillar issue to this.
Hope it help

Android, Bluemix Error 401 : You are not authorized

I downloaded the sdk from here, created an application but when i run the app the logcat notifies:
Error 401, Failure: You are not authorized.
I tested the Bluemix app with the sample code you can find here, obviously switching the default parameters with my app's ones.
Solved.
I downloaded the April jars, the most recent ones. That worked.
A 401 error sounds as if the Mobile Application Security (MAS) is not set up correctly. Could you try going to your mobile back end on Bluemix, clicking the MAS service, turning the "Enable Client List" switch to on, and then adding your bundle id under iOS? Additionally, confirm that you've copied the client-id & client secret correctly into the properties file for the application.

unable to cast to personal whitelisted receiver app

I have successfully used the Android TicTacToe app to cast to the TicTacToe receiver app (AppID "TicTacToe"), using unmodified code from the TicTacToe example on github.
Next, I tried to use my personal receiver app. I got the email a couple of hours letting me know that my device was whitelisted and providing the AppID. I put the AppID in line 90 on GameActivity.java (not line 91, as stated in the instructions), and I also put it in line 35 of tictactoe.html (this step was missing from the instructions, but I assume it is needed). I also followed all steps in the Common Errors section of the instructions.
When I click the Start button in the Android app, the Tic-Tac-Toe board appears in the Android app, but the Chromecast device does not noticeably react.
Here is the LogCat:
07-28 00:13:47.776: W/StartSessionTask(10892): StartApplicationRequest failed with status: -4
07-28 00:13:47.826: E/ApplicationSession(10892): StartSessionTask failed with error: failed to start application: request failed
07-28 00:13:47.826: D/GameActivity(10892): start session failed: failed to start application: request failed
Try checking the box that says "Send this Chromecast's serial number when checking for updates".
Mine didn't work at first, after doing this and restarting mine seemed to pick up the whitelisted appID.
As mentioned by the author of question: Make sure to do from ChromeOS, Windows or Mac OSX client until they fix the issue from Android app.
Clients can be downloaded here: https://cast.google.com/chromecast/setup
This was fixed for me after I restarted the chromecast by removing power.
I tried Aaron's answer several times (was finally able to get the setting to stick using the Chromecast Mac app) but it still was giving this same error.
Then, I discovered I actually uploaded the receiver file to the wrong url. So double check which url was actually whitelisted!
Though even after fixing the url it still was broken. So I think I must have entered the wrong serial number when I made the whitelist request. I resent the whitelist request and the new app ids are working properly.
I solved same problem by using HTTP instead of HTTPS for my local hosted receiver, it seems Chromecast looks for valid certificate.

Android - Worklight Hybrid application fails to connect to server in the emulator

I created a worklight application. I tried running that application on android emulator and i am getting the following error.
[http://localhost:8080/apps/services/api/MyFirstApp/android/query] Host is not responsive.
Try to manually access the URL through the android emulator browser to verify connectivity
So i tried to enter the same url in the emulator browser, i got the following text:
/*-secure-
{"WL-Authentication-Failure": {"wl_remoteDisableRealm":{"reason":"Login Failed}}} */
Can someone help me with this?
I am using Android OS version: 4.2.2, API level: 17
I haven't changed any application settings myself..
I am trying to go to a basic login page with the url "https://jazz.net/jazz/auth/j_security_check"
This is my adapter XML:
<wl:adapter xmlns:wl="worklight.com/integration"; xmlns:http="worklight.com/integration/http"; xmlns:xsi="w3.org/2001/XMLSchema-instance"; name="RQMAdapter">
<displayName>RQMAdapter</displayName>
<description>HTTP type Worklight Adapter for jazz server</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>https</protocol>
<domain>jazz.net</domain>
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="2" />
</connectivity>
<procedure name="loginToRQM" />
</wl:adapter>
This is my scenario:
I have a requirement where I need to read information about the projects from jazz.net for a user. They are all available on the jazz server within an XML file. I need to process it to a mobile device to make it available on hand held device... So, now I am told that i will have to download some of the files from the server, so i need to have file IO on my app. I learned that we need to write this part using a Cordova plug-in in Worklight.
please let me know what else is needed for the solution... thank you
Make sure to place the actual IP address of your server machine:
Change the value for worklightServerRootURL in the file
application-descriptor.xml (located at: yourProject\apps\yourApp)
Build and deploy
Right-click on the generated Android project >> Run As >> Run application
If you are using using Worklight 5.0.5, make sure to upgrade to 5.0.6, where a fix is available when only API Level 17 is installed.
As for going to that URL, you need to explain where exactly you're trying to go to it from, and how... you need to be more descriptive. It sounds to me like you haven't gone through the Getting Started material. Please do.
I had the same problem.
I have solved it by using the real IP address of the server in the WL app instead of using localhost:
When the emulator is running your app, press the Menu button.
Select to change your server URL
Remove "localhost" and use the IP address.
Accept and try again.
This fixed my problem.

Internet access on Android device behind proxy with authentication

I am unable to connect to the Internet through android emulator 2.2 which is behind a proxy that requires proxy authentication.
Searched a lot over the Internet to find a proper solution but none of them are working for me.
I am running the emulator on a Ubuntu machine.
Situation:
I have an application which is designed to run on both ubuntu(linux) and android.
This application has a feature to connect to internet by providing proxy details and it connects properly when run on ubuntu after providing correct details. however this fails to connect through the emulator.
Even the web browser on the emulator doesn't connect to internet. Doing some changes in APN settings, it atleast gave me a webpage saying that the ISA server needs authentication, but never got any popup requesting to enter those details.
By applying -debug-proxy flag to emulator, the logs showed that it is trying to connect to the requested proxy server, but the server is challenging with authentication and none of the applications seem to get a chance to fill in this details and hence failing. This is what is happening with my application.
Does anyone have any clue why this could be happening and how i can resolve this issue?
Thanks in advance.
P.S. This is happening on actual android devices as well, so it may not be the problem of just the emulator.
Puneet ... Do as viv said and along with this give proxy address in its IP format instead of giving its DNS name. I have read some where that it is having problem in resolving DNS name.
Tell me if I'm wrong but I think Puneet is talking about wifi connection. So the solution is not to configure an APN as it's for mobile networks. I got the same problem and I'm still searching for a solution...
There is a simple method by which you can get internet access on the device but only for browsing. Except the browser no other apps will have access to internet. You can find detailed information on http://androidproxy.blogspot.in/2011/01/setting-up-proxy.html.
In order to get the IP address just ping the proxy server in your organisation. By default the port is 8080.
You can use Proxy Manager application to connect to internet from behind a authenticated proxy.
Try this:
Go to setings -> wireless and networks -> Mobile networks -> Access point name.
If you see any entry here, edit it's settings
I know this is an old post but just for people asking the same question, I did connect from my phone in proxy network that required authentication by using the Autoproxy app that is now in the android market: https://market.android.com/details?id=com.mgranja.autoproxy_lite&feature=search_result&rdid=com.mgranja.autoproxy_lite&rdot=1&pli=1
if you use webview, you can override onReceivedHttpAuthRequest method of webviewclient when set it.
mWebView.setWebViewClient(new WebViewClient() {
#Override
public void onReceivedHttpAuthRequest(WebView view,HttpAuthHandler handler,String host, String realm) {
handler.proceed("username", "password");
}
});

Categories

Resources