Cannot access Google App Engine in browser - google-app-engine

I am making an application on Google App Engine, and want to run the app locally and test requests with Postman. I start the server locally with:
python3 main.py
I then get the following:
* Serving Flask app "main" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 257-782-471
I can view the app perfectly using "web preview" and "preview on port 8080".
When i click on the link " http://127.0.0.1:8080/ " , it redirects me to " https://8080-dot-12856039-dot-devshell.appspot.com/?authuser=0&environment_name=default " that works, but i cannot access this in postman.
When i type in http://127.0.0.1:8080/ in the web browser or in Postman, i get no response and a The site is not available error
When i deploy the application the URL and everything works fine, but i dont want to deploy the whole application each time i want to check something with requests. I just want to run it and access it locally.
Does anyone know what i am doing wrong?

Based on the information that you are providing, I assume that you are running the python3 main.py command in the Cloud Shell.
Then when you click on Web Preview or Preview on port 8080, this is creating an SSH tunnel from your Cloud Shell to the Virtual Machine that is hosting the resources behind the scenes, and this process is allowing you to connect and test the app by navigating either to 127.0.0.1:8080 or https://8080-dot-12856039-dot-devshell.appspot.com/?authuser=0&environment_name=default.
In short, if you want to issue GET or POST requests, you can open another tab in the Cloud Shell and use curl in order to achieve the similar behavior you are trying with Postman. With Postman you are trying to access from outside and you don't have access to the URL.
This information is explained in the Cloud Shell documentation.

Related

ReactJS browser app cannot see things in the Docker Compose network

I have a ReactJS project with its own Dockerfile, exposing port 3000:3000.
I also have a PHP project with its own Dockerfile, exposing port 80:80. The PHP app also has containers for MySQL, Redis and Nginx
For the PHP app, I have a docker-compose file that creates a network (my-net) for PHP, Nginx, MySQL and Redis to communicate on. However, I now want the ReactJS (which is in a separate project) to be able to communicate with the PHP app.
I added a docker-compose file to the React project, and added it to the network from the PHP project my-net and declared it as external so that it doesn't try to create it.
This seems to work: From the ReactJS container, I can ping app (the name of my backend service) and it works properly. However, from the ReactJS code, if I use something like axios to try and hit the backend API, it can't resolve app or http://app or any variation. It can however access the underlying IP address if I substitute that into in axios.
So there seems to be some issue with the hostname resolution, and presumably this is on the axios / JavaScript end. is there something I'm missing or a reason this isn't working?
When the JavaScript runs in a browser (outside of Docker) you can not use app because that is only available inside the Docker network (via the embedded DNS server).
To access your PHP server from outside use localhost and the exposed port (80) instead.

Flask + Flask-SocketIO return 404 for route when requesting from Ionic client

I am working on a real-time chatting and photo sharing application. I use Flask as my server side to build RESTful web services and use Ionic framework (AngularJS) to build my client on mobile.
I have a web service endpoint [GET] /feeds/user_id which returns new feeds of a user. When I use the following line of code to initialize my app, I can correctly retrieve data from both localhost and my application running on mobile.
app.run(host='0.0.0.0', debug=True)
As I build the app with real-time chat, I use Flask-SocketIO and I change the way to initialize my app to the one below, as specified in the official documentation.
socketio.run(app, host='0.0.0.0', policy_server=False)
However, I cannot retrieve data from my mobile app now with the above way of initialization. One of the sample log is:
192.168.1.100 - - [2015-09-13 23:38:32] "GET http://192.168.1.101:5000/feeds/1 HTTP/1.1" 404 342 0.002000
However, I am able to retrieve data from my localhost and another machine in the same network using the same link, so I am sure the server is listening to all public IPs. I have also disabled my firewall.
My code snippet below:
from app import socketio, app
if __name__ == '__main__':
socketio.run(app, host='0.0.0.0', policy_server=False)
# app.run(host='0.0.0.0', debug=True)
Any help is appreciated!
Update: When I only use app.run(), the log is as below:
192.168.1.110 - - [20/Sep/2015 00:17:23] "GET http://192.168.1.103:5000/feeds/1 HTTP/1.1" 200 -
As Miguel mentioned, this is a weird log but it works, so thanks to the robustness of Flask!
I also tried to run my app on iOS, which works perfectly fine. Now I suspect it is an issue of Ionic framework on Android platform, or just on my device. My device is Nexus 7 Gen 1, running Android 5.1.1.
I resolved my problem myself.
Flask and Flask-SocketIO does not start the same type of server - Flask starts standard Werkzeug development web server, but Flask-SocketIO starts gevent web server. That's why I see the different behaviours as I mentioned in the question, but the problem is not with Flask.
The real problem lies in how the built-in WebView handles the HTTP requests to server side. In my device, it seems that the WebView handles the requests in a strange way - I did not look into this in detail. As a result of this, the gevent web server is not able to handle this HTTP request - resulting in 404.
The way I solved this is by packaging the WebView of latest Chrome version into my app. I do it using Crosswalk. It perfectly resolved my problem.

App Engine works when access by version specific url, but not by the main url

The Problem:
I can access my Cloud Endpoints API via the following version-specific URL:
https://[version]-dot-[myappid].appspot.com/...
but I can't access it via this main URL:
https://[myappid].appspot.com/...
the error I receive in the chrome console is this:
https://[myappid].appspot.com/_ah/api/discovery/v1/apis/userEndpoint/v1/rpc?fields=methods%2F*%2Fid&pp=0 404 (Not found)
What I've done:
First off let me say I'm very new to App Engine so apologies if this is a silly question.
I've created a Google Cloud Endpoints Backend module as part of my project in Android Studio (v0.5.6) which uses all the new gradle stuff and Objectify annotations.
I've tested my back end locally on the dev server and it all runs fine.
I then deployed it to appengine using the gradle task appengineUpdate and all went well.
I deleted previous version instances running in my app engine cloud console and made the newly deployed version (version-2) the default.
I can access and use the endpoint API fine via the version specific URL as described above but not via the main url.
I have a simple index.html file which is using the endpoint via the javascript client library to test with before building client libraries for my android app.
On both versions of the URL the index.html file renders properly, it just can't connect to the API.
If anyone knows how I can get the app to run properly on the main URL (or let me know if it's not supposed to) that would be awesome!
Many thanks!
Solution was to use appengineUpdateAll which calls both: appengineUpdate and appengineUpdateAllBackends my bad!

Can't deploy Google App Engine application on local server

I am trying to follow the instructions for running a simple new Google App Engine web application locally (without Google Web Toolkit, just the Web App) named "tunes".
I am following these instructions. Step one is to make a run configuration. I made one using all the defaults; I checked that under the Server tab the "Run built-in Server" box is checked. However, when I Run the app, I get the Console; right below the console tab it says
&ltterminated> tunes [Web Application] C:\Program Files (x86)\Java\jre7\bin\javaw.exe (Feb 26, 2014, 5:35:44 PM)
then below the line is what looks like a classic Unix "Usage" error message in the console, in red type, whose first line is
Usage: &ltdev-appserver> [options] &ltapp directory>
followed by a list of options, and then nothing else happens that I can see.
I tried pointing a browser at http://localhost:8888/tunes as suggested by the documentation, but Firefox could not find a server active at that port.
Under the Arguments tab in the Run Configuration is the following:
"-codeServerPort 9997 --port=8888 org.tunes.gaeproject.Tunes C:\Users\cdf\java\eclipse4.3.1workspace\tunes\war"
I can successfully deploy the web application to the Google App Engine site and run it there.
What do I have misconfigured?
Google AppEngine application is not meant to run on local server, and neither you could create its docker image etc to deploy it anywhere you wish.
Instead I suggest you to port your application to Google Compute Engine (GCE) first within your deployment setup, which might require minor code refactorings, and Kubernetes kinda auto-scaling deployment will functional equivalent to what you have now. But with approach you may port the application easily to local server setup, or a docker image to run from any virtualization environment

How to test a Facebook application on Google App Engine locally (code 191 error)?

I want to test and develop locally, while having the application on the air, and I'd rather not use two separate application id's because this means I have to change the code every time I deploy a new version and then change it back.
I understand that I can change the host file so that localdev.{{my application URL}} would refer to localhost and the URL will be valid, so I won't get the 191 code, but the Google App Engine launcher forces me to use port 8080, and this can't be defined in the host files. If I try to enter localdev.{{my application URL}}:8080 I get the 191 error code again.
Is there any way to use port 80 with the Google App Engine launcher?
Or is there another solution?
UPDATES:
I managed to run locally on port 80 by using the Python file from the Google App Engine directory and not the Google App Engine launcher GUI. However, Facebook doesn't recognize localdev.{{my application URL}} as the URL, and it still gives me the same error code, 191.
Once I changed the host file into {{my application URL}} without the "localdev." it worked, so this must mean the URLs must match exactly, and not just the domain. Is this true? Anyway, it isn't optimal, because it means I have to change the host file all the time, but it's something you can live with...
I have 2 Facebook apps, one with my real URL (for production), and one with http://127.0.0.1/ (for development). Then I have a utility function in my code which checks self.request.host, and selects the appropriate app id and secret.
The reason I use http://127.0.0.1/ and not http://localhost/ or http://localhost:8080/ is that I found only http://127.0.0.1/ would work in Internet Explorer (other browsers seemed fine with those other two URLs, provided they matched the Facebook app).

Resources