I am new to this Socket.io library. May be I am missing something trivial. I am using Flask for server side and javascript for client side. Both sides are able to 'emit' data and call functions on the other side. However, when I have a long running python (it takes about 20 mins to execute) function whose result I want to capture and transmit to client side, looks like the connection is getting dropped. How do I fix this?
Client side, I have this:
var socket = io.connect('http://' + document.domain + ':' + location.port);
On server side:
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app, logger=False, ping_timeout=100, engineio_logger=False)
@socketio.on('long_process')
def long_process(message):
data_back_to_client = call_long_running_code()
emit('client_results', {'data': data_back_to_client})
However, by the time call_long_running_code() returns, the connection drops (socket is closed).
How do I make sure the connection persists so that the server side can transmit the results once the long running process is done running. Happy to provide more code or context.