I have created a hybrid mobile app using ionic 2. The app can connect to a Django-powered website on a localhost through Rest API when using "ionic serve" command (using web browser on my end device).
Now, I want to use the app using Bluestacks as emulator. The Django website and the API (running on the localhost) can be accessed through the browser app of the bluestacks. Here were the steps I performed to do this one:
Installed allow-control-allow-origin to enable cross origin information sharing on Google Chrome on my local device.
I have added ALLOWED_HOSTS = ['10.0.2.2'] in my django settings.
Access the django website through Bluestacks' browser using
http://10.0.2.2:8000/
However, the mobile app emulated in Bluestacks could not access the API. Any solution to this problem?
The django conf look's OK.
With this kind of problem, in general, i use tools like :
localtunnel (free)
ngrok
to acces to my localhost from everywhere
example with lt :
$ lt -p 8000 -s andynionic
your url is: https://andynionic.localtunnel.me
You must also add andynionic.localtunnel.me to the Django config
ALLOWED_HOSTS = ['10.0.2.2', 'andynionic.localtunnel.me']
with hibrid, you probably do CORS request, see also cors-django
hope it's help
Related
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'm trying to test a website in the Android Emulator. The website is required to run on HTTPS. Outside the emulator on my PC the website is running fine with SSL, because I use an official certificate which is bound to https://localhost. When I run the website in the emulator I can access in on https://10.0.2.2, but I get a warning and a red 'https' in Chrome (10.0.2.2 is the address to access localhost on the host machine).
Is there any way to get it use a certificate?
A common solution is to use a tool like ngrok which creates a web available HTTPS site that will proxy requests to a specific port on your local machine. Then you open https://examplexyz.ngrok.io in the emulator and you have a valid TLS certificate and your local development website.
Chrome browser and others will show a warning about security when your website use a self-signed certificate. Please ignore it if you are testing at localhost. When you publish your website to production and have a domain, you can use a free SSL certificate Let's Encrypt.
I have a beginners question.
I deployed my meteor website on Galaxy. Now I want an android version of my website. I followed every step in mobile docs. Everything is working fine on windows and the app is working as expected in the emulator.
Now if I build my app for production, we need to give a host and port.
What port and host should I use so I can use the same code base as my website?
Here is My domain
I tried:
meteor build ../output --server http://heybuddy.meteorapp.com:80
But without success. Or do I see it totally wrong.
Thank you for any answers!
The host is where your server is accessible, typically the address you use to access the browser-based version of your application / website.
The port is not mandatory.
I am currently developing a cordova 4.3 android app in Visual Studio 2015 RC. It's an AngularJS app and I use $resource to send requests to an ASP.NET Web Api application running on a different port on the same computer. Debugging the app in Ripple works fine if I disable the Cross Domain Proxy but when I try to debug in the Visual Studio Android Emulator or on my Android device I get a not very helpful "Failed to load resource" as soon as try to reach the web api. The url looks correct and I suspect the problem has to do with either CORS or my HTTPS certificate or both? What I have tried so far is:
Set <uses-permission android:name="android.permission.INTERNET" /> and android:debuggable="true" in the manifest file.
Tried chrome://inspect/#devices to get more info about the problem but got the error message "Cannot load DevTools frontend from an untrusted origin".
I am able to connect my android phone chrome web browser to the localhost web api using the very helpful tool sharpproxy [https://www.codefromjames.com/wordpress/?p=97] but this approach unfortunately does not work with the app's webview.
The ajax request does work when I point the app to my azure hosted live web api endpoint where I have a valid https certificate but that is not very convenient to use while developing the app.
Made sure the config.xml-file contains <access origin="*" />
My web api is configured with app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll)
I am completely new to cordova/hybrid app development and am surely missing some obvious thing? Any help or suggestion would be very appreciated!!
After having all sort of problems with Visual Studio 2015 I uninstalled it went back to Visual Studio 2013 Update 4 and now I can connect my android device to a local running web api using sharp proxy I mentioned and linked to above.
So to be clear:
Use Visual Studio 2013 Update 4 to run your web api on for example the url https://localhost:44358/.
Start sharp proxy with external port 5000 and internal 44358.
Make sure your android device is connected to the same wifi and instruct your app to use https://your-ip-address:5000 for all service calls.