manatlan / guy

Graphics User Ynterface : a simple module for making GUI applications (with html/js) for py3 ... to target windows, linux, mac & android
Apache License 2.0
202 stars 23 forks source link

Chrome - net::ERR_CONNECTION_REFUSED - memory full #29

Open inillaug opened 3 years ago

inillaug commented 3 years ago

Hello manatlan,

I i run for example testEmit.py in server mode instead of app mode.

if name == "main":

Emit( ).run()

Emit( ).serve(open=False, port=8000 ,log=False, autoreload=False)

If i close the server the Chrome console give me the following error:

Emit_2a1a630-js:9 WebSocket connection to 'ws://127.0.0.1:8000/Emit_2a1a630-ws' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

After 5 minutes Chrome become unusable, the memory consumption encrease and the console give me the following error:

Emit_2a1a630-js:9 WebSocket connection to 'ws://127.0.0.1:8000/Emit_2a1a630-ws' failed: Unknown reason setupWS @ Emit_2a1a630-js:9 (anonymous) @ Emit_2a1a630-js:57

The only way to avoid this modify guy.py at line 896;

ws.onclose = function(evt) {
    guy.log("** WS Disconnected");
    //setTimeout( function() {setupWS(cbCnx)}, 500);
};
ws.onerror = function(evt) {
    guy.log("** WS Disconnected");
    //setTimeout( function() {setupWS(cbCnx)}, 500);

Do you think this is interesting for others? May be an option like app.serve(... , autoreloadws=True/False)?

manatlan commented 3 years ago

really interesting ... in fact, the guy/js on client/side(when your tab is always opened) will try to reconnect indefinitely ... and I think it can increase the memory consumption ...

The only solution, to avoid this : guy should stop its attempts after a number of tries, or after a delay

latot commented 3 years ago

Maybe, with every try is creating new elements all the time and there the memory consuption, or, with every try lookup a way to clean the memory