mongodb - How to fix Flask-Pymongo Server TimeOut Error? -
i trying connect mongodb using flask-pymongo.
if uri 'mongodb://username:password@localhost/db' getting error this. if use pymongo instead flask-pymongo working fine. can me doing wrong.
[wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] mod_wsgi (pid=11570): target wsgi script '/var/www/flaskapp/flaskapp.wsgi' cannot loaded python module., referer: http://104.196.184.145/ [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] mod_wsgi (pid=11570): exception occurred processing wsgi script '/var/www/flaskapp/flaskapp.wsgi'., referer: http://104.196.184.145/ [mon aug 21 19:47:24.659190 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] traceback (most recent call last):, referer: http://104.196.184.145/ [mon aug 21 19:47:24.659213 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] file "/var/www/flaskapp/flaskapp.wsgi", line 7, in <module>, referer: http://104.196.184.145/ [mon aug 21 19:47:24.659290 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] flaskapp import app application, referer: http://104.196.184.145/ [mon aug 21 19:47:24.659298 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] file "/var/www/flaskapp/flaskapp/__init__.py", line 14, in <module>, referer: http://104.196.184.145/ [mon aug 21 19:47:24.659325 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] mongo = pymongo(app), referer: http://104.196.184.145/ [mon aug 21 19:47:24.659332 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] file "/var/www/flaskapp/flaskapp/venv/lib/python2.7/site- packages/flask_pymongo/__init__.py", line 97, in __init__, referer: http://104.196.184.145/ [mon aug 21 19:47:24.659444 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] self.init_app(app, config_prefix), referer: http://104.196.184.145/ [mon aug 21 19:47:24.659449 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] file "/var/www/flaskapp/flaskapp/venv/lib/python2.7/site- packages/flask_pymongo/__init__.py", line 283, in init_app, referer: http://104.196.184.145/ [mon aug 21 19:47:24.659459 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] mechanism=auth_mechanism), referer: http://104.196.184.145/ [mon aug 21 19:47:24.659464 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] file "/var/www/flaskapp/flaskapp/venv/lib/python2.7/site- packages/pymongo/database.py", line 1075, in authenticate, referer: http://104.196.184.145/ [mon aug 21 19:47:24.659774 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] connect=true), referer: http://104.196.184.145/ [mon aug 21 19:47:24.659782 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] file "/var/www/flaskapp/flaskapp/venv/lib/python2.7/site- packages/pymongo/mongo_client.py", line 542, in _cache_credentials, referer: http://104.196.184.145/ [mon aug 21 19:47:24.660067 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] writable_preferred_server_selector), referer: http://104.196.184.145/ [mon aug 21 19:47:24.660075 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] file "/var/www/flaskapp/flaskapp/venv/lib/python2.7/site- packages/pymongo/topology.py", line 214, in select_server, referer: http://104.196.184.145/ [mon aug 21 19:47:24.660293 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] address)), referer: http://104.196.184.145/ [mon aug 21 19:47:24.660302 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] file "/var/www/flaskapp/flaskapp/venv/lib/python2.7/site- packages/pymongo/topology.py", line 189, in select_servers, referer: http://104.196.184.145/ [mon aug 21 19:47:24.660312 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] self._error_message(selector)), referer: http://104.196.184.145/ [mon aug 21 19:47:24.660349 2017] [wsgi:error] [pid 11570:tid 140000932448000] [client 75.145.147.36:61878] serverselectiontimeouterror: no servers found yet, referer: http://104.196.184.145/
my flaskapp.config file
wsgipythonhome "/var/www/flaskapp/flaskapp/venv/local/bin" wsgipythonpath "/var/www/flaskapp/flaskapp/venv/lib/python2.7/site-packages" <virtualhost *:80> servername 104.196.184.145 serveradmin asd@gmail.com wsgiscriptalias / /var/www/flaskapp/flaskapp.wsgi <directory /var/www/flaskapp/flaskapp/> order allow,deny allow </directory> alias /static /var/www/flaskapp/flaskapp/static <directory /var/www/flaskapp/flaskapp/static/> order allow,deny allow </directory> errorlog ${apache_log_dir}/error.log loglevel warn customlog ${apache_log_dir}/access.log combined </virtualhost>
flaskapp.wsgi file
#!/usr/bin/python import sys import logging logging.basicconfig(stream=sys.stderr) sys.path.insert(0,"/var/www/flaskapp/") flaskapp import app application application.secret_key = 'your secret key. if share website, not share key.'
i enable security authorization on mongod.conf file , created user in mongoshell , able login in mongoshell. using pymongo 3.5 , flask-pymongo 0.5.1
wiki
Comments
Post a Comment