python - Nginx 阻止数据库操作 mongodb flask
问题描述
我有一个烧瓶脚本,用于通过 pymongo 使用 Mongodb。它在开放的 5000 端口上工作正常,但是当我想通过 nginx 访问它时,出现错误
对于这个项目,我使用 nginx>uwsgi sock>wsgi.py> app.py uwsgi>wsgi.py>app.py 在开放 5000 端口上不使用 nginx 工作
server {
listen 80;
server_name my_ip;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/viktor/my_project/project.sock;
}
}
Oct 11 12:05:08 funloot3 uwsgi[11123]: Traceback (most recent call last):
Oct 11 12:05:08 funloot3 uwsgi[11123]: File "/home/funloot/funloot/flaskenv/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
Oct 11 12:05:08 funloot3 uwsgi[11123]: response = self.full_dispatch_request()
Oct 11 12:05:08 funloot3 uwsgi[11123]: File "/home/funloot/funloot/flaskenv/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request
Oct 11 12:05:08 funloot3 uwsgi[11123]: rv = self.handle_user_exception(e)
Oct 11 12:05:08 funloot3 uwsgi[11123]: File "/home/funloot/funloot/flaskenv/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception
Oct 11 12:05:08 funloot3 uwsgi[11123]: reraise(exc_type, exc_value, tb)
Oct 11 12:05:08 funloot3 uwsgi[11123]: File "/home/funloot/funloot/flaskenv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
Oct 11 12:05:08 funloot3 uwsgi[11123]: raise value
Oct 11 12:05:08 funloot3 uwsgi[11123]: File "/home/funloot/funloot/flaskenv/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
Oct 11 12:05:08 funloot3 uwsgi[11123]: rv = self.dispatch_request()
Oct 11 12:05:08 funloot3 uwsgi[11123]: File "/home/funloot/funloot/flaskenv/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
Oct 11 12:05:08 funloot3 uwsgi[11123]: return self.view_functions[rule.endpoint](**req.view_args)
Oct 11 12:05:08 funloot3 uwsgi[11123]: File "./app.py", line 230, in my_stat
Oct 11 12:05:08 funloot3 uwsgi[11123]: result = push_step(uid, request.args.get('steps'), request.args.get('timestamp'), request.args.get('check'))
Oct 11 12:05:08 funloot3 uwsgi[11123]: File "./app.py", line 169, in push_step
Oct 11 12:05:08 funloot3 uwsgi[11123]: step_user = steps_db.find_one({'uid': uid})
Oct 11 12:05:08 funloot3 uwsgi[11123]: File "/home/funloot/funloot/flaskenv/lib/python3.6/site-packages/pymongo/collection.py", line 1273, in find_one
Oct 11 12:05:08 funloot3 uwsgi[11123]: for result in cursor.limit(-1):
Oct 11 12:05:08 funloot3 uwsgi[11123]: File "/home/funloot/funloot/flaskenv/lib/python3.6/site-packages/pymongo/cursor.py", line 1156, in next
Oct 11 12:05:08 funloot3 uwsgi[11123]: if len(self.__data) or self._refresh():
Oct 11 12:05:08 funloot3 uwsgi[11123]: File "/home/funloot/funloot/flaskenv/lib/python3.6/site-packages/pymongo/cursor.py", line 1050, in _refresh
Oct 11 12:05:08 funloot3 uwsgi[11123]: self.__session = self.__collection.database.client._ensure_session()
Oct 11 12:05:08 funloot3 uwsgi[11123]: File "/home/funloot/funloot/flaskenv/lib/python3.6/site-packages/pymongo/mongo_client.py", line 1807, in _ensure_session
Oct 11 12:05:08 funloot3 uwsgi[11123]: return self.__start_session(True, causal_consistency=False)
Oct 11 12:05:08 funloot3 uwsgi[11123]: File "/home/funloot/funloot/flaskenv/lib/python3.6/site-packages/pymongo/mongo_client.py", line 1760, in __start_session
Oct 11 12:05:08 funloot3 uwsgi[11123]: server_session = self._get_server_session()
Oct 11 12:05:08 funloot3 uwsgi[11123]: File "/home/funloot/funloot/flaskenv/lib/python3.6/site-packages/pymongo/mongo_client.py", line 1793, in _get_server_session
Oct 11 12:05:08 funloot3 uwsgi[11123]: return self._topology.get_server_session()
Oct 11 12:05:08 funloot3 uwsgi[11123]: File "/home/funloot/funloot/flaskenv/lib/python3.6/site-packages/pymongo/topology.py", line 482, in get_server_session
Oct 11 12:05:08 funloot3 uwsgi[11123]: None)
Oct 11 12:05:08 funloot3 uwsgi[11123]: File "/home/funloot/funloot/flaskenv/lib/python3.6/site-packages/pymongo/topology.py", line 205, in _select_servers_loop
Oct 11 12:05:08 funloot3 uwsgi[11123]: self._error_message(selector))
Oct 11 12:05:08 funloot3 uwsgi[11123]: pymongo.errors.ServerSelectionTimeoutError: No replica set members found yet
屏幕截图中的追溯
解决方案
推荐阅读
- python - 为什么是“从 CAUSE 中引发异常”,而不是“从 CAUSE 中引发异常”?
- arrays - 检查特殊数组方程的子集总和
- amazon-dynamodb - DynamoDb 从 Node.js 更新项目
- rest - Microsoft Graph:假设 plannerTask.id 和 plannerTaskDetails.id 始终相同是否安全?
- java - Android 应用程序:当我一次性从 API 中放入大约 300 条记录时,RecyclerView 挂起
- sinon - Loopback 4:测试Sinon和注入的问题
- python - 如何使用 pipenv 指定在哪里创建虚拟环境?
- redux - 我试图用 redux 获取输入,一切都很好,但我不知道如何获取输入值
- java - 是什么导致了这个异常:java.lang.NoSuchFieldException?
- yesod - Yesod Hamlet 通过用双引号替换单引号来破坏 HTML