In the answer to the question Error sending e-mail via SMTP server on App Engine development server there is a nice solution by Blixt:
"dev_appserver.py does not support TLS
which is required by Gmail. You can
enable it by adding a few lines in api/mail_stub.py:"
# After smtp.connect(self._smtp_host, self._smtp_port)
smtp.ehlo()
smtp.starttls()
smtp.ehlo()
But windows Vista would not let me change api/mail_stub.py
Is there another way to send mail from development server. Other options (Sendmail and ISP are not good for me). Thanks!
EDIT
I changed the api/mail_stub.py according to instructions here and I use the following command-line options:
dev_appserver.py
--smtp_host=smtp.gmail.com
--smtp_port=25
--smtp_user=xxxx#gmail.com
--smtp_password=gmail_pw
C:\Users\A\Desktop\repeater # path to root directory
But I get this error from Log Console:
***********************************************************
2010-11-18 10:24:37 Running command: "['C:\\Python26\\pythonw.exe',
'C:\\Program Files(x86)\\Google\\google_appengine\\dev_appserver.py',
'--admin_console_server=',
'--port=8080',
u'dev_appserver.py',
u'--smtp_host=smtp.gmail.com',
u'--smtp_port=25',
u'--smtp_user=xxxx#gmail.com',
u'--smtp_password=gmail_pw
C:\\Users\\A\\Desktop\\repeater',
'C:\\Users\\A\\Desktop\\repeater']"
Runs a development application server for an application.
dev_appserver.py [options] <application root>
Application root must be the path to the application to run in this server.
Must contain a valid app.yaml or app.yml file.
****************************************************
This is the app.yaml:
application: re-peater
version: 1
runtime: python
api_version: 1
handlers:
- url: /favicon.ico
static_files: static/images/favicon.ico
upload: static/images/favicon.ico
- url: /stylesheets
static_dir: stylesheets
- url: /.*
script: repeater.py
All this works without these command line options. Any suggestions why this is not working?
If you really, really need to send real email from the dev_appserver, you should set up your own mail relay on your machine, and point the SDK at that. I'm curious why it's so important to send real email, though - this is the development server, and you shouldn't be using it for anything other than development.
Change the file permissions so that you can change the api/mail_stub.py file.
This is no longer necessary
in /appengine/api/mail_stub.py
if self._allow_tls and smtp.has_extn ('STARTTLS'):
smtp.starttls ()
I am using appengine sdk version 1.9.15.
Related
I am still working to get my old style appengines to work under at least go111 (go112 would not work due to dependencies on memcache). I am now stumbling over app.yaml configuration issues with my static files, I used a completely static directory layout before and just specified a few dynamic handlers in the root like this:
runtime: go111
handlers:
- url: /_ah/.*
script: auto
login: admin
secure: always
- url: /dynamic
script: auto
secure: always
- url: /admin/.*
script: auto
login: admin
secure: always
- url: (.*)/
static_files: html\1/index.html
upload: html/index.html
secure: always
- url: /(.*\.map)
mime_type: application/json
static_files: html/\1
upload: html/(.*\.map)
secure: always
- url: /
static_dir: html
secure: always
dev_appserver.py will never call my dynamic entry point. In production this does work, but I am still working on the conversion and would like to test locally. Any hints how to convince dev_appserver.py to let me do this? By the way my gcloud tools are updated as of today.
Your question is why your application works well when you deploy it to production but doesn't work when you use dev_appserver.py to run it locally, and how could you run it with dev_appserver.py. The answer to that is:
You won't be able to run it locally properly using dev_appserver.py, since it does not support runtime Go 1.11. Look at the Local Development Server Options documentation, there's only a link for "Go 1.9".
(as you can see, the links for "Go 1.11" and "Go 1.12" are disabled, which translates to: not supported.)
Documentation for Go 1.11 on App Engine Standard states that in order to test your application locally you would have to use "go run" command (notice how it doesn't mention dev_appserver.py tool). The command would be something like this:
go run [build flags] [-exec xprog] package [arguments...]
For more information about the command go here.
I'm sure you might have already read this but, to know more about the migrations process from Go1.9 to Go1.11 read this documentation.
You have stated that "go run" command wouldn't work for your case. So, a workaround for that would be to test your application directly into App Engine but without migrating the traffic.
When deploying your test version use:
gcloud app deploy --no-promote
To access to it go to:
http://VERSION_ID.default.YOUR_PROJECT_ID.appspot.com
If everything turned out great, you can migrate the traffic on the Cloud Console UI selecting the version you just deployed and clicking "Migrate traffic".
I am creating an offline-first app on Google App Engine, with PouchDB as my local DB, and CouchDB as my remote DB. I have enabled CouchDB on Google AppEngine, and tried to go to the following URL:
https://[my-app-id].appspot.com:5984/_utils/
When I do that, I get the following:
This site can’t be reached
The connection was reset.
Try:
Checking the connection
Checking the proxy and the firewall
Running Windows Network Diagnostics
ERR_CONNECTION_RESET
So I tried enabling https access in the firewall settings.
**Firewalls**
[ ] Allow HTTP traffic
[Y] Allow HTTPS traffic
Still getting the error above.
I searched the documentation but cannot find anything helpful about how to access Fauxton (or Futon) on Google AppEngine. (The instructions only tell you how to access Fauxton on your local machine.)
I have generated a private and public key and logged in to the server via command line.
I have also followed the instructions about configuring the firewall to allow remote access, and have given it to my PC only.
None of this has enabled me to access https://[my-app-id].appspot.com:5984/_utils/
How do I access Fauxton on the Google AppEngine platform?
Update: according to the development tools in my browser, my PouchDB application has successfully created a database to sync to, but it isn't on the server:
app.yaml file
application: [app-name]
version: 4
runtime: python27
api_version: 1
threadsafe: false
handlers:
- url: /
script: main.py
- url: /(favicon)\.ico$
static_files: \1.ico
upload: /(favicon)\.ico
application_readable: true
- url: /(package)\.json$
static_files: \1.json
upload: /(package)\.json
application_readable: true
# Serve images as static resources #
- url: /(.+\.(gif|png|jpg|json|ico))$
static_files: \1
upload: .+\.(gif|png|jpg|json|ico)$
application_readable: true
- url: /index.html
static_files: index.html
upload: index.html
- url: /licence.html
static_files: licence.html
upload: licence.html
- url: /privacy.html
static_files: privacy.html
upload: privacy.html
- url: /pouchnotes.manifest
static_files: pouchnotes.manifest
upload: pouchnotes.manifest
- url: /manifest.json
static_files: manifest.json
upload: manifest.json
# static directories #
- url: /img
static_dir: img
- url: /js
static_dir: js
- url: /css
static_dir: css
libraries:
- name: webapp2
version: "2.5.2"
EDIT: I posted this question in the Bitnami community forum (they provide CouchDB on Google App Engine)
FWIW, one of the references in your post points to Google Compute Engine (GCE), which is an IaaS, not a PaaS like Google App Engine (GAE), you might be looking at the wrong product.
The app.yaml file indicates you are using the standard environment, which doesn't offer ways to configure a listening port. And it also doesn't allow listening sockets. From Limitations and restrictions:
Although App Engine supports sockets, there are certain limitations
and behaviors you need to be aware of when using sockets :
You cannot create a listen socket; you can only create outbound sockets.
The GAE flexible environment might be an alternative as it drops many of the standard environment restrictions, but it's a significantly different solution (which I didn't use yet). The remainder of the answer assumes the flexible environment and it's based solely on the documentation.
Not 100% certain, but you might need to teach your app to listen to port 8080 instead. From Listen to port 8080:
The App Engine front end will route incoming requests to the
appropriate module on port 8080. You must be sure that your
application code is listening on 8080.
Unless you can use the forwarded ports network config (again, not 100% certain, I didn't use flex env). From Port forwarding:
Port forwarding allows for direct connections to the Docker container
on your instances. This traffic can travel over any protocol. Port
forwarding is intended to help with situations where you might need to
attach a debugger or profiler.
By default, incoming traffic from outside your network is not allowed
through the Google Cloud Platform firewalls. After you have
specified port forwarding in your app.yaml file, you must add a
firewall rule that allows traffic from the ports you want opened.
You can specify a firewall rule in the Networking Firewall Rules page
in the Google Cloud Platform Console or using gcloud
commands.
For example, if you want to forward TCP traffic from port 2222:
Modify the app.yaml to include:
entrypoint: gunicorn -b :$PORT -b :2222 main:app
In the network settings of your app.yaml, include:
network:
forwarded_ports:
- 2222/tcp
Specify a firewall rule in the Cloud Platform Console or using gcloud compute firewall-rules create to allow traffic from any
source (0.0.0.0/0) and from tcp:2222.
I'm getting some help with this from the Bitnami Community Forum.
Answers so far...
(1) set up the firewall rules - make sure you have a permanent IP address for this.
(2) set up SSH keys to access the server via command line
(3) sudo /opt/bitnami/couchdb/scripts/ctl.sh stop couchdb
(4) edit local.ini to point to 0.0.0.0 instead of 127.0.0.1 - but note that you will need to type cd /opt/bitnami/couchdb/etc/, press enter, and then sudo vi local.ini (rather than vi local.ini as the instructions suggest).
(5) Log in to the external IP address. (Log in as admin and prefix commands with sudo)
(NB: you don't need to run this in the GAE flexible environment)
I have been trying to deploy my project on Google Cloud SDK since yesterday and have been getting the same error over and over.
My app.yaml file looks like:
runtime: python27
api_version: 1
threadsafe: yes
- url: /
static_files: bin/index.html
upload: bin/index.html
- url: /assets
static_dir: bin/assets
- url: /src
static_dir: bin/src
- url: /vendor
static_dir: bin/vendor
- url: /templates-app.js
static_files: static/templates-app.js
upload: static/templates-app.js
- url: /templates-common.js
static_files: static/templates-common.js
upload: static/templates-common.js
- url: .*
script: main.app
I use this command to deploy:
gcloud preview app deploy app.yaml --version 1 --promote --force
And I get this error:
Beginning deployment...
Copying files to Google Cloud Storage...
Synchronizing files to [gs://staging.myapp.appspot.com/].
Updating module [default]...failed.
ERROR: (gcloud.preview.app.deploy) Error Response: [13] An internal error occurred.
I got the same error today Error Response: [13] An internal error occurred.
In my case, the issue was because I have a folder that has over 1000 files. Once I moved some of these files elsewhere, the internal error message disappeared!
I tried 1000 files in one folder, and it worked, then, I added one file (1001 files total) in the same folder, and the same internal error came back. It seems that it is kind of a limit that google app engine has 1000 files per folder.
I notice you don't have your app name in the app.yaml file and you also don't specify it in the upload cmd. I'd suggest making a habit in providing as much as the info as possible in the app.yaml to minimize the chances of human error. You can also specify the version in the app.yaml as well. This habit will help when you'll get to multi-modules apps, where such info is mandatory. See examples in the modules config doc.
From a different prospective, I saw several reports in which gcloud preview app deploy tripped, you can always try alternate approaches to rule out such cases, see my answer to this Q&A: Google App Engine deploy with Django module after gcloud update?
It ended up being the reportlab python library in the lib folder.
I found inserting it as a zip file rather than a normal folder worked.
import sys
sys.path.insert(0, 'reportlab.zip')
import reportlab
...
I have no idea why it wouldn't work. But I remember seeing something about a file limit when uploading projects with app-engine. Deploying 1 zip file is better than 181 files that make up reportlab.
I'm facing a problem where a static file is showing up correctly on the local machine via dev_appserver.py but once uploaded to the server it doesn't show and gives me a 404 error.
The partial directory file structre is:
- static/
articles.html
images/*.png
The partial app.yaml file is:
runtime: go
api_version: go1
- url: /(articles\.html)
static_files: static/\1
upload: static/*.html
I then to access this via the http url appname.appspot.com/articles.html.
I downloaded the code after I put it on the appengine server to ensure that articles.html has actually been uploaded in the said directory, and it has. So the exact same file structre locally and on the server, but it gives a 404 on the server and works locally. I have the latest versions of the appengine. Any help on what I could be doing wrong?
thanks in advance
Sathish
Just putting this up for completeness ... I went back and tried various reasonable combinations again and found that this config works:
- url: /(articles)\.html
static_files: static/\1.html
upload: static/.*.html
It is ridiculous of me to make the claim now, but I remember attempting a regex for the "upload" entry earlier and it hadn't worked. So, I don't clearly know the issue, however, my best guess is that dev_appserver.py is probably taking some shortcuts to serve static files and not behaving exactly like the appengine would. I shall raise an issue on that and see if there is any resolution or clarification.
I am running my app on the production server for first time. I have a url with admin logon enabled in the app.yml. The script runs when I browse to its URL when running on the development server. However, after uploading to the production server when I go to the same URL I get the following error:
The requested URL /tasks/ was not found on this server.
Why would this occur? I tried updating again.
The URL and script is the third one in the my app.yml file:
##app.yml file
application: generic_app_name
version: 1
runtime: python
api_version: 1
handlers:
- url: /remote_api
script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
login: admin
- url: /stats.*
script: $PYTHON_LIB/google/appengine/ext/appstats/ui.py
- url: /tasks/SR2pop
script: PopulateSR2.py
login: admin
- url: /
script: dbsample.py
Is the capitalization of your script exactly as specified in app.yaml? The production servers are case-sensitive, but if you're developing on Windows, the development server isn't. Check the capitalization of PopulateSR2.py matches the one in app.yaml.
Also, your file is called app.yaml, not app.yml, right?
Your 3rd handler is going to match only the exact string /tasks/SR2pop. None of your handlers will match /tasks/.