I use Android Studio create a Emulator, I known this Emulator has a ip (10.0.2.2).
And I want to send request api to LAN server, by coincidence this
ip:port is 10.0.2.*:8087.
so I get this response:
Failed to connect to /10.0.2.*:8087
how can I deal with situation
Related
I have a .netcore SignalR server running locally through ISS express. (https://localhost:44372/secureChat")
I have an Android Emulator running through Android Studio.
For referencing localhost things via the emulator you use the ip 10.0.2.2.
I'm using the microsoft signalR android package: com.microsoft.signalr:signalr
I using the hubConnectionBuilder to connect to: https://10.0.2.2:44372/secureChat
When I attempt to connect I get the following error: java.lang.RuntimeException: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
I've found solutions online but none of them relate to SignalR or socket connections.
Alternatively I also have a website that connects to the local signalR server and when I launch the website locally and then host that inside a WebView in android app, it works fine (webview connected at https://10.0.2.2:3000) , but I'm trying to experiment with connecting directly from Android without the webview.
Does anybody have any idea what I need to do to resolve this issue?
The problem is that your android emulator doesn't trust the self signed certificate of iis express, export the certificate to a file, upload to the emulator and follow this link to add the certificate https://support.google.com/nexus/answer/2844832?hl=en
In my Android emulator, I was able to contact the GAE dev server.
I use this url: "http://10.0.2.2:8080/myurl".
The server is listening on http://127.0.0.1:8080.
Then, after I've updated the emulator to the Nexus 5X version with Google Play(API 27), the connection fails and the server show this log:
ERROR 2018-01-11 11:17:05,463 wsgi_server.py:329] Request Host 10.0.2.2 not whitelisted. Enabled hosts are set(['127.0.0.1'])
I'm using the latest GAE python SDK with webapp2.
Any idea on how to solve the problem?
The more recent versions of the development server includes whitelisting checks of the source IP address of incoming requests.
You can use the --enable_host_checking=False command line option for the GAE devserver, which disables these checks. Not a good idea if you're running on an untrusted network.
You're probably seeing such errors even for accessing the devserver from the same machine. Another option for these requests would be to use the --host 10.0.2.2 devserver option (i.e. use your machine's external IP address instead of localhost/127.0.0.1, but that won't help with the emulator requests if you're running the emulator on some other machine.
Ideally the whitelist should IMHO be manageable independently from the server's IP address, but this is what is available presently.
I'm behind a corporate proxy and everything that access the internet needs a special configuration regarding Proxy. I'm on a CentOS 7, using CNTLMD to handle proxy tunneling, developing for mobile with React Native. And I'm using the Android Emulator provided by Android Studio.
I first noticed that my emulator can't access any HTTPS protocol when I tried to open Google in the Browser. Internally google redirects to HTTPS and I always get that "Connection Refused" error. Later (this week), trying to use Axios and Fetch to make HTTP/HTTPS requests, this has become a serious problem, since the APIs I'm trying to connect to are under the HTTPS protocol.
A friend of mine who is working in the same project but using Mac has no problems with HTTPS. I have also tried to start the emulator with the following commands:
emulator -avd myemulator -http-proxy http://127.0.0.1:3128
And
emulator -avd Marshmallow86 -http-proxy http://<network username>:<network password>#<ip>:<port>
And they do nothing.
I tried setting up HTTP and HTTPS proxy on Android Studio but this don't seem to be the way (and also didn't work).
#edit
I set the http_proxy on my host and started the emulator without parameters. Didn't work as well.
What am I missing?
I haven't used the software above that isn't android avd or androidstudio,
but it looks like a proxy or CA certificate problem.
Since the difference seems to be by OS, I would guess CA certificate first.
This android page has advice on using openssl from the command line to
explore that and consider importing certificates.
https://developer.android.com/training/articles/security-config.html
This android page has current suggestions for proxy configurations:
https://developer.android.com/studio/run/emulator-networking.html
Note, that the above instructions are updated for new features.
In the past I needed a proxy to a non-ssl appengine development server
which is slightly different from your problem but here's what I used:
For an SSL proxy, used the apache web server, and configured it to use SSL
by installing a self-signed certificate, then added a ProxyPass and ProxyPassReverse
in httpd.conf and a ProxyPass in the httpd-ssl.conf.
ProxyPass / http://127.0.0.1:8080/
Apache as an SSL proxy receives connections to https://127.0.0.1:443 and
passes them to http://127.0.0.1:8080
Then in the application, code that will be running in the emulator
can use address
10.0.2.2 to use android subnet routing table to connect to the dev. OS localhost.
I followed this tutorial to setup a cloud database for my Android App
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloEndpoints
Everything compiled fine and the server is running at http://localhost:8080/
However I keep getting this error
failed to connect to /10.0.0.2(port 8080) after 20000ms
I tried replacing 10.0.0.2 with my local IP address but it didn't work and showed the same error.
I am using Android Studio and debugging the app on my Android phone. Kindly help. Thanks!
Couple of areas to check:
Make sure you can connect to your locally running server using local IP address. In in your computer browser go to :8080. If it doesn't work then make sure your Run/Debug Config in AS is calling 127.0.0.1 or 0.0.0.0 address.
your android app has to be calling your pc's local IP address.
You need to start the dev server listening on 0.0.0.0. By default, the dev server listens only on localhost which means requests from other devices will not work. Just edit your run configuration and set the server address.
First find the IP Address of your machine (e.g., 192.168.x.x), by using ifconfig.
Change your build.gradle file of the endpoints project by adding this code appengine.run.host='192.168.x.x' at the end of the file.
Change the address in your android code with .setRootUrl("http://192.168.x.x:8080/_ah/api")
I trying to deploy an android application connected to GAE. I run the online tutorial on google, I used the right configuration (as they write on the tutorial) but I can't communicate the Android Virtual Device with the web application running locally. The Web application shows me a "Server Error 500" and the android application on AVD shows me a "Failure:Connect to /192.168.56.1:8888 timed out" error.
I m running Eclipse Indigo and the virtual android device is with Google API Level 10.
Thank you.
Appengine dev server by default only accepts connections on localhost address (localhost and 127.0.0.1).
To make it accept connections on all ports add -bindAddress 0.0.0.0 to dev server parameters in Eclipse.