AWS Elastic Beanstalk-会话不可用错误

时间:2019-01-25 21:18:55

标签: python flask amazon-elastic-beanstalk

我正在尝试在AWS Elastic Beanstalk上运行一些Flask应用程序。由于某些原因,我有以下异常:      RuntimeError:该会话不可用,因为未设置任何秘密密钥。将应用程序上的secret_key设置为唯一且秘密的内容。

mod_wsgi (pid=28948): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
Traceback (most recent call last):
File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask_restplus/api.py", line 583, in error_router
return original_handler(e)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask_restplus/api.py", line 583, in error_router
return original_handler(e)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
 raise value
File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask_login/utils.py", line 260, in decorated_view
return current_app.login_manager.unauthorized()
File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask_login/login_manager.py", line 167, in unauthorized
flash(self.login_message, category=self.login_message_category)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/helpers.py", line 410, in flash
session['_flashes'] = flashes
File "/opt/python/run/venv/local/lib/python3.6/site-packages/werkzeug/local.py", line 350, in __setitem__
self._get_current_object()[key] = value
File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/sessions.py", line 101, in _fail
raise RuntimeError('The session is unavailable because no secret '
RuntimeError: The session is unavailable because no secret key was set.  Set the secret_key on the application to something unique and secret.

这很奇怪,因为我创建了环境变量,并且secret_key var存在。另外,我添加了以下代码:

app = Flask(__name__) 
app.config.from_object(ConfigHelper.set_config(sys.argv)) #<-- select config
app.secret_key = app.config['SECRET_KEY']

我什至不知道此代码是否被调用。我真的很困惑。有人遇到这个问题吗?谢谢!

UPD。好像我想通了。我添加了从http到https的自动重定向,但由于未设置https侦听器,因此无法正常工作。为什么我看到此错误消息仍然是一个难题...

0 个答案:

没有答案