You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using flask, socketio for a chatbot. Locally everything works fine, I can ask bot questions and I get answers. On Heroku server, I get the following Error:
[2020-04-06 09:18:35 +0000] [10] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/geventlet.py", line 99, in init_process
super().init_process()
File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 119, in init_process
self.load_wsgi()
File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
self.wsgi = self.app.wsgi()
File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
return self.load_wsgiapp()
File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
return util.import_app(self.app_uri)
File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 358, in import_app
mod = importlib.import_module(module)
File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/app/app.py", line 7, in <module>
from controllers.question_controller import model
File "/app/controllers/question_controller.py", line 12, in <module>
model = QuestionAnswerer(data, domain_name, ftp_username, ftp_password)
File "/app/.heroku/python/lib/python3.7/site-packages/socialworks_nn/question_answerer.py", line 14, in __init__
super().__init__(json_data)
File "/app/.heroku/python/lib/python3.7/site-packages/socialworks_nn/data_preprocessing/data_processing.py", line 11, in __init__
download('punkt')
File "/app/.heroku/python/lib/python3.7/site-packages/nltk/downloader.py", line 787, in download
for msg in self.incr_download(info_or_id, download_dir, force):
File "/app/.heroku/python/lib/python3.7/site-packages/nltk/downloader.py", line 636, in incr_download
info = self._info_or_id(info_or_id)
File "/app/.heroku/python/lib/python3.7/site-packages/nltk/downloader.py", line 609, in _info_or_id
return self.info(info_or_id)
File "/app/.heroku/python/lib/python3.7/site-packages/nltk/downloader.py", line 1019, in info
self._update_index()
File "/app/.heroku/python/lib/python3.7/site-packages/nltk/downloader.py", line 962, in _update_index
ElementTree.parse(urlopen(self._url)).getroot()
File "/app/.heroku/python/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/app/.heroku/python/lib/python3.7/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/app/.heroku/python/lib/python3.7/urllib/request.py", line 543, in _open
'_open', req)
File "/app/.heroku/python/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/app/.heroku/python/lib/python3.7/urllib/request.py", line 1360, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/app/.heroku/python/lib/python3.7/urllib/request.py", line 1317, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/app/.heroku/python/lib/python3.7/http/client.py", line 1252, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/app/.heroku/python/lib/python3.7/http/client.py", line 1298, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/app/.heroku/python/lib/python3.7/http/client.py", line 1247, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/app/.heroku/python/lib/python3.7/http/client.py", line 1026, in _send_output
self.send(msg)
File "/app/.heroku/python/lib/python3.7/http/client.py", line 966, in send
self.connect()
File "/app/.heroku/python/lib/python3.7/http/client.py", line 1422, in connect
server_hostname=server_hostname)
File "/app/.heroku/python/lib/python3.7/site-packages/eventlet/green/ssl.py", line 438, in wrap_socket
return GreenSSLSocket(sock, *a, _context=self, **kw)
File "/app/.heroku/python/lib/python3.7/site-packages/eventlet/green/ssl.py", line 76, in __new__
*args, **kw
TypeError: wrap_socket() got an unexpected keyword argument '_context'
[2020-04-06 09:18:35 +0000] [10] [INFO] Worker exiting (pid: 10)
[2020-04-06 09:18:35 +0000] [4] [INFO] Shutting down: Master
[2020-04-06 09:18:35 +0000] [4] [INFO] Reason: Worker failed to boot.
Here is the code where I run my server:
from flask import Flask, render_template, session
from models import db
from flask_restful import Api
from flask_socketio import SocketIO, emit
from controllers.image_controller import ImageController
from controllers.question_controller import model
app = Flask(__name__)
app.config.from_object("config.Config")
app.config['SECRET_KEY'] = '123456'
db.init_app(app)
socketio = SocketIO(app)
api = Api(app)
api.add_resource(ImageController, '/images')
@app.route('/chatbot')
def index():
return render_template('index.html', async_mode=socketio.async_mode)
@socketio.on('my_event', namespace='/chatbot')
def test_message(question):
answer = model.get_answer(question['data'])
session['receive_count'] = session.get('receive_count', 0) + 1
emit('my_response', {'data': answer, 'count': session['receive_count']})
if __name__ == '__main__':
socketio.run(app, debug=True, use_reloader=False)
I am using flask, socketio for a chatbot. Locally everything works fine, I can ask bot questions and I get answers. On Heroku server, I get the following Error:
Here is the code where I run my server:
Here is my requirements.txt file:
Here is my Procfile:
web: gunicorn --worker-class eventlet -w 1 app:app
Here is my .gitlab-ci.yml file:
Also, my runtime.txt:
python-3.7.5
I have followed the documentation https://flask-socketio.readthedocs.io/en/latest/#gunicorn-web-server, but I have no idea why this error keeps appearing. I am new to websockets, any help will be appreciated. Maybe there is somekind of workaround this issue?
The text was updated successfully, but these errors were encountered: