Flask SocketIO timeout when using web server instead of localhost

  docker, flask-socketio, gunicorn, nginx, sockets

I am working on a basic web messaging app with Flask, that I am deploying using docker with gunicorn as the wsgi and nginx for my proxy server. Everything works on localhost when I run the containers, but I get an error when I am trying to send messages via sockets to my remote server, running the same container constellation. More specifically, I am told that the socket timed out. This is strange because all non-socket interactions are very quick, while not actually being more computationally intensiv (message are sent almost instantly when working locally).

Socket framework I am using is Flask-SocketIO and I am processing messages using eventlet. My function for receiving and emitting when a user sends a message is done with the following code:

@socketio.on('post message')
def add_new_msg(data):
    data['isPending'] = False
    if len(data['message']) <= 0:
    sql_query = 'INSERT INTO messages (chatroomid, messagecontent, timestamp, sendername) '
    sql_query += 'SELECT :chatroomid, :messagecontent, :timestamp, :sendername '
    sql_query += 'WHERE EXISTS (SELECT 1 FROM chatrooms WHERE chatroomid = :chatroomid)'
    row_count = db.execute(sql_query, {
                'chatroomid': data['roomId'],
                'messagecontent': data['message'],
                'timestamp': data['timestamp'],
                'sendername': data['username']
    if row_count > 0:
        emit('server message callback', data, broadcast=True)

thanks in advance for any suggestions.

Added the error log.

app_1         | [2019-06-16 13:53:59 +0000] [8] [ERROR] Socket error processing request.
app_1         | Traceback (most recent call last):
app_1         |   File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base_async.py", line 66, in handle
app_1         |     six.reraise(*sys.exc_info())
app_1         |   File "/usr/local/lib/python3.6/site-packages/gunicorn/six.py", line 625, in reraise
app_1         |     raise value
app_1         |   File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base_async.py", line 56, in handle
app_1         |     self.handle_request(listener_name, req, client, addr)
app_1         |   File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base_async.py", line 129, in handle_request
app_1         |     six.reraise(*sys.exc_info())
app_1         |   File "/usr/local/lib/python3.6/site-packages/gunicorn/six.py", line 625, in reraise
app_1         |     raise value
app_1         |   File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base_async.py", line 107, in handle_request
app_1         |     respiter = self.wsgi(environ, resp.start_response)
app_1         |   File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__
app_1         |     return self.wsgi_app(environ, start_response)
app_1         |   File "/usr/local/lib/python3.6/site-packages/flask_socketio/__init__.py", line 44, in __call__
app_1         |     start_response)
app_1         |   File "/usr/local/lib/python3.6/site-packages/engineio/middleware.py", line 59, in __call__
app_1         |     return self.engineio_app.handle_request(environ, start_response)
app_1         |   File "/usr/local/lib/python3.6/site-packages/socketio/server.py", line 428, in handle_request
app_1         |     return self.eio.handle_request(environ, start_response)
app_1         |   File "/usr/local/lib/python3.6/site-packages/engineio/server.py", line 340, in handle_request
app_1         |     environ, start_response)
app_1         |   File "/usr/local/lib/python3.6/site-packages/engineio/socket.py", line 106, in handle_get_request
app_1         |     start_response)
app_1         |   File "/usr/local/lib/python3.6/site-packages/engineio/socket.py", line 146, in _upgrade_websocket
app_1         |     return ws(environ, start_response)
app_1         |   File "/usr/local/lib/python3.6/site-packages/engineio/async_drivers/eventlet.py", line 20, in __call__
app_1         |     return super(WebSocketWSGI, self).__call__(environ, start_response)
app_1         |   File "/usr/local/lib/python3.6/site-packages/eventlet/websocket.py", line 130, in __call__
app_1         |     self.handler(ws)
app_1         |   File "/usr/local/lib/python3.6/site-packages/engineio/socket.py", line 160, in _websocket_handler
app_1         |     pkt = ws.wait()
app_1         |   File "/usr/local/lib/python3.6/site-packages/eventlet/websocket.py", line 788, in wait
app_1         |     for i in self.iterator:
app_1         |   File "/usr/local/lib/python3.6/site-packages/eventlet/websocket.py", line 643, in _iter_frames
app_1         |     message = self._recv_frame(message=fragmented_message)
app_1         |   File "/usr/local/lib/python3.6/site-packages/eventlet/websocket.py", line 669, in _recv_frame
app_1         |     header = recv(2)
app_1         |   File "/usr/local/lib/python3.6/site-packages/eventlet/websocket.py", line 578, in _get_bytes
app_1         |     d = self.socket.recv(numbytes - len(data))
app_1         |   File "/usr/local/lib/python3.6/site-packages/eventlet/greenio/base.py", line 366, in recv
app_1         |     return self._recv_loop(self.fd.recv, b'', bufsize, flags)
app_1         |   File "/usr/local/lib/python3.6/site-packages/eventlet/greenio/base.py", line 360, in _recv_loop
app_1         |     self._read_trampoline()
app_1         |   File "/usr/local/lib/python3.6/site-packages/eventlet/greenio/base.py", line 331, in _read_trampoline
app_1         |     timeout_exc=socket_timeout('timed out'))
app_1         |   File "/usr/local/lib/python3.6/site-packages/eventlet/greenio/base.py", line 210, in _trampoline
app_1         |     mark_as_closed=self._mark_as_closed)
app_1         |   File "/usr/local/lib/python3.6/site-packages/eventlet/hubs/__init__.py", line 159, in trampoline
app_1         |     return hub.switch()
app_1         |   File "/usr/local/lib/python3.6/site-packages/eventlet/hubs/hub.py", line 298, in switch
app_1         |     return self.greenlet.switch()
app_1         | socket.timeout: timed out

Source: StackOverflow