Monodroid GenyMotion access internet through code - android-emulator

I have struggling for the past week to try to get this to work. I have downloaded this fantastic tool which is the genymotion emulator for android. But I can't access the internet from my line of code.
using( WebClient wbclient = new WebClient() )
{
try
{
String URI = "http://www.timeapi.org/utc/now"; // test purpose only
Stream s = wbclient.OpenRead( URI );
using( StreamReader r = new StreamReader( s ) )
{
string str = r.ReadToEnd();
}
}catch(Exception ex)
{
// handle...
}
}
This is a simple service that returns the time. If I enter this address in the browser of the guest device genymotion ( android 4.2.2 - API 17 ), the browser works perfectly and the time is returned. But the above code throws an exception "Connection time out". Why within my guest device the above url can be retrieved from the browser and properly display the time and throw an exception when access in code via WebClient object? Thanks

It's not your code: you have discovered that genymotion is not on the internet - this flaw is by official design. this happens because genymotion (a wrapper for VirtualBox) dis-disconnects the correct adapters (that you may or may not have set in VirtualBox) and uses it's own (faulty) "Host Only Adapter" networking setting instead, and then HIDES that it does this.
To fix this highly unfair "bug" (feature?) you have to go into VirtualBox, find the GenyMotion machine by name and then power it off, right click to "Settings" networking and then click under "adapter 2" (tab) and tick "enable network adapter" then click "attached to:>Bridged Adapter" assuming your pc that you are running it all on runs under DHCP it will set up a IP for the Android VM that GenyMotion proclaims as it's own (which it is not)

Related

IBM Watson api.eu-gb.dataplatform.cloud.ibm.com’s server IP address could not be found?

I start learning data science in IBM and I enroll in the course where we had to join in IBM cloud (lite) and then to create Watson studio(lite). I just followed the document and after creating Watson studio (lite) I got this error:
api.eu-gb.dataplatform.cloud.ibm.com’s server IP address could not be found
It prevent me from seing the button "Get start" which I must click on
I tried to see solution but I didn't find anything and also I talked with watson in chatbox you provide support but the solution watson give didn't help me.
Link to course:
https://developer.ibm.com/digitalnation/africa/skills/innovator-predict-employee-turnover-using-ibm-watson-studio/?module=02.03
For more info see my screenshot: "click here" to see the screen shot i take it
Investigation
I am unable to reproduce the issue.
The Watson Studio Instance Dashboard loads successfully for me in the London data center.
I highly suspect that your current web browser settings might be preventing the iframe'd content area from loading.
Suggested Follow-up Actions
(a) Try disabling your Ad blocker and reloading the page (ad blockers are known to block content from loading in iframes).
(b) Try loading the page in a new incognito window (this will disable all browser extensions).
(c) Try loading the page in another web browser (e.g. Firefox, Edge, Safari).
(d) Try clearing your cookies for the cloud.ibm.com domain and reloading the page.
(e) In your web browser, type Control+Shift+J (on Windows) or Command+Option+J (on Mac) to open the Developer Tools and take a screenshot of any errors you see in the Console tab (and post it back here).
Reference: https://developers.google.com/web/tools/chrome-devtools/shortcuts
(f) Try visiting the direct URL below to see if the page loads.
Direct URL
https://api.eu-gb.dataplatform.cloud.ibm.com/dsx-service-broker/ui/console?plan_id=40073cbd-2d60-4a65-a32d-3b1d11794cc6
Work-around
Go directly to the Watson Studio Registration Page (which is the URL for the Get Started button)
https://eu-gb.dataplatform.cloud.ibm.com/registration/steptwo?redirectIfAccountExists=True&apps=watson_studio
Can you run dig api.eu-gb.dataplatform.cloud.ibm.com or nslookup api.eu-gb.dataplatform.cloud.ibm.com? I am guessing its an issue with your DNS provider on your current network. Can you try another network or wifi connection? For reference here is the nslookup I just did with it.
nslookup api.eu-gb.dataplatform.cloud.ibm.com
Server: 10.xxx.xxx.xxx
Address: 10.xxx.xxx.xxx#53
Non-authoritative answer:
api.eu-gb.dataplatform.cloud.ibm.com canonical name = api.watson-data-prod-lon.eu-gb.containers.appdomain.cloud.
api.watson-data-prod-lon.eu-gb.containers.appdomain.cloud canonical name = watson-data-prod-lon.eu-gb.containers.appdomain.cloud.
Name: watson-data-prod-lon.eu-gb.containers.appdomain.cloud
Address: 158.175.100.214
Name: watson-data-prod-lon.eu-gb.containers.appdomain.cloud
Address: 158.176.125.222
Name: watson-data-prod-lon.eu-gb.containers.appdomain.cloud
Address: 141.125.66.126
try using vpn supporting browser like opera it worked with me since I'm from Egypt and had the same error

Katalon Studio not able to run test in Chrome

I recorded a test case on Chrome and wanted to run the test. When I run it, it just opens up a browser and doesn't add the URL
If I open in Firefox, the URL is added but the proxy settings default to no proxy (but I am behind a firewall)
How do I get the test to run on either Firefox or Chrome?
Please help
To set proxy in case of Firefox, you have to use profiles in WebDriver.
FirefoxProfile profile = new FirefoxProfile();
profile.addAdditionalPreference("network.proxy.http", "localhost");
profile.addAdditionalPreference("network.proxy.http_port", "8888");
WebDriver driver = new FirefoxDriver(profile);
To execute testcase in Chrome, you need Chromedriver.
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
You can set proxy like this.
ChromeOptions options = new ChromeOptions();
Proxy proxy = new Proxy();
proxy.setHttpProxy("localhost:8888");
options.setCapability("proxy", proxy);
ChromeDriver driver = new ChromeDriver(options)

Side-loaded Windows 8.1 application generates an exception when calling methods of an RESTful Web API

I have developed a Line-of-Business (LOB) Windows 8.1 application for one of our clients. The app was developed in Visual Studio 2015, on my 64-bit Windows 8.1 Enterprise laptop. The application makes use of a RESTful Web API that is running under IIS Express on the same laptop. The IIS Express has been configured to expose the RESTful Web API to the outside world, such that I can make Web API calls with Fiddler from a different machine. My app works just fine when I test it with the VS2015 Simulator, even when I configure it to use the correct IP address of the Web API (not the localhost).
The client wants to deploy this app in production on some DELL tablets that will run Windows 10. I have one of these tablets and it has 64-bit Windows 10 Enterprise on it. When I side-load my app on the tablet, I launch it and I save in its settings the URL for the Web API service. I relaunch the app, but the first call into the Web API fails to complete. I log an exception informing me that "An error occurred while sending the request". The inner exception message is "Unable to connect to the remote server". The line of code that triggers this exception is this one:
HttpResponseMessage response = await WebApiHttpClient.GetAsync("api/user", HttpCompletionOption.ResponseContentRead).ConfigureAwait(continueOnCapturedContext: false);
where the WebApiHttpClient object is a class static member constructed like this:
if (WebApiHttpClient == null)
{
WebApiHttpClient = new HttpClient(WebApiAuthClientHandler)
{
BaseAddress = new Uri(_serviceUri), // _serviceUri is a string that looks like this "http://10.120.5.201:53045"
Timeout = new TimeSpan(0, 0, 150)
};
WebApiHttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
The WebApiAuthClientHandler is also a class static member that is instantiated like this:
if (WebApiAuthClientHandler == null)
{
WebApiAuthClientHandler = new HttpClientHandler()
{
Credentials = CredentialCache.DefaultNetworkCredentials,
ClientCertificateOptions = ClientCertificateOption.Automatic
};
}
The exception is triggered about 21 seconds after my call so it can't be a timeout since the timeout is set to 150 seconds.
The Web API is running on my laptop, as I mentioned before and using the node.js iisexpress-proxy tool I managed to expose the local URL to the outside world so that I can make Web API calls using Fiddler running on the tablet.
Also, in my app's Package.appxmanifest/Capabilities I have checked the "Private Networks (Client & Server)".
The Event Viewer does not log any additional information.
Can anyone make a suggestion on why the error is triggered?
TIA,
Eddie
The error message I have in my 3rd comment was caused by the fact that I had Fiddler running at the same time. When running without Fiddler, the application receives a different error, but that will be the subject of a different question here, on StackOverflow.

How to create SOAPAdater using IBM worklight 6.2?

I am trying to create Soap Adapter using IBM Work light but I am not able to get web services methods to work light projects Services folder. When I am running my project after deployment of adapter it will not showing proper output. Let me know if anyone had made demo or some good Links related to it.
Your explanation does not provide the steps you have actually taken nor the expected output, the service you are using, the error you're getting, etc... so it is somewhat difficult to understand/recreate the issue... Also, please do mention the build number of the Worklight Studio 6.2 installation you're using.
There is no such thing as a "SOAP adapter" per-se. What you are referring to is "HTTP adapter" that is generated by providing a WSDL scheme location.
For example, WebServiceX.net provides a global weather service.
In order to generate an adapter from the above:
Create a new project
In the project structure, right-click on the Services folder and select "Discover back-end services"
From the "Service type" dropdown, select "Web Service Definition Language (WSDL)"
In the "URL" field paste "http://www.webservicex.net/globalweather.asmx?WSDL" and click on "Go"
From the "Select Service" table, select a service and click on "Finish"
The end result is a new HTTP adapter in the adapters folder called "SoapAdapter1", containing an auto-generated XML and -impl.js file ready to use.
You can read more about it, here:
HTTP adapters training module, slide #16
Generating adapters with the services discovery wizard user documentation topic
I also suggest using the very latest iFix available for the 6.2.0.1 release, as it contains some WSDL-related fixes, so best to be up-to-date.
It can be downloaded from either IBM Fix Central or from the Eclipse Marketplace (Eclipse > Help > Marketplace).
Finally I have successfully consume weather Soap service.
Below given is main function which should call after successful connection.
function loadContactSuccess(result){
WL.Logger.debug("Device is connected to WL server");
WL.Logger.info("Inside loadContactSuccess" );
var list = result.invocationResult.Envelope.Body.GetWeatherInformationResponse.GetWeatherInformationResult.WeatherDescription;
console.log("list detail ..." + list);
sessionStorage.setItem("WeatherDescription", JSON.stringify(result.invocationResult.Envelope.Body.GetWeatherInformationResponse.GetWeatherInformationResult.WeatherDescription));
WL.Logger.debug("WeatherDescription list :: ", JSON.parse(sessionStorage.getItem("WeatherDescription")));
var tempValue = JSON.parse(sessionStorage.getItem("WeatherDescription"));
console.log("Inside loadContactSuccess ..." + tempValue.length);
text = "";
var i;
for (i = 0; i < tempValue.length; i++) {
text += tempValue[i].WeatherID +" "+"<img src="+ tempValue[i].PictureURL +">" + "<br>";
}
document.getElementById("demo").innerHTML = text ;
}
You can also download demo example create by me from URL.Click Here

Android / Eclipse / Emulator / WAMP: Error 503 and timeouts

I am trying to request JSON data from a PHP script in my Android app.
The whole thing works well when I'm directly connecting my mobile phone and directly access the "real" Internet webserver. However, it doesn't work at all using the emulator and localhost (WAMP installation). Running the script directly on the local webserver, again, gives me the expected results- only if I am calling it on the same machine using the emulator, the troubles begin.
Here are the combinations I have tried so far (the scripts are located in the subdirectory "zz" of the root):
private static String url_all_venues = "http://10.0.2.2/zz/pullvenuesjson.php";
or
private static String url_all_venues = "http://10.0.2.2:80/zz/pullvenuesjson.php";
leads to the following exception: E/JSON Parser(657): Error parsing data org.json.JSONException: Value
When I'm trying the following:
private static String url_all_venues = "http://10.0.2.2:8080/zz/pullvenuesjson.php";
the code runs 'forever' and I'm getting a timeout error after about 5 minutes.
Any idea how to fix that so I can also test my app on my local webserver / the emulator? Most probably the problem is in my local Apache configuration, but then, I'm not sure…
EDIT:
Here is some of the code that seems to trigger the error:
DefaultHttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
"url" is the one mentioned above. As mentioned in my comment below, it looks as if the problem comes from the local WAMP webserver not responding appropriately, since the code works fine when I'm directly accessing the "real" server via the Internet (i.o.w, do nothing else than changing the URL to the Internet address of the php script). The odd thing is that the script also works fine when I run it locally, but NOT through the emulator.
I finally figured it out! I logged the transferred data using Log.d(..) and found out that the username/password combination was not valid as I didn't check for the localhost condition... The script and app retrieves the data just fine now on both, localhost and the web. Thanks for your inquiries which helped me to get down to the root of the error!
[Answered myself in order to avoid the Q showing up as unanswered]