python-eel / Eel

A little Python library for making simple Electron-like HTML/JS GUI apps
MIT License
6.44k stars 587 forks source link

ERR_CONNECTION_REFUSED #355

Closed WMoraes13 closed 3 years ago

WMoraes13 commented 4 years ago

what this error means?

error: eel.js:115 WebSocket connection to 'ws://localhost:8000/eel?page=select_ger.html' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

samuelhwilliams commented 4 years ago

It likely means that the bottle server isn't available on port 8000. Did you get any errors from the python side?

WMoraes13 commented 4 years ago

I'm not having any errors on the python side ... I created an executable using pyinstaller. When I run my app on my computer it works perfectly but when I try to run it, I use another machine and I always get this connection error.

parthbyt commented 4 years ago

I am also facing the same issue, it happens always whenever it try to use multiple pages. I have to restart the app 2 or 3 times to fix it.

OuthBack commented 4 years ago

Same happens with me

samuelhwilliams commented 4 years ago

Could someone share their code that exhibits this problem?

OuthBack commented 4 years ago

This problem don't happens all the time, only sometimes. When I reload multiple times, the same error shows up. image

OuthBack commented 4 years ago

I recorded this error: https://youtu.be/RrttD375Fwg

parthbyt commented 4 years ago

When I go for next page in my app, The python program stops even before closing the window and at console following error occur (Chrome):

WebSocket connection to 'ws://localhost:5010/eel?page=news/news.html' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED (anonymous) @ eel.js:115

And after this error if I click for next page the same error occur as described by @OuthBack

I have identified few cases where this error generally occur:

  1. When there is heavy load on CPU
  2. When I close the program directly from console. Next time this error occur.
  3. The number of pages I increase, more commonly I see this error.
OuthBack commented 4 years ago

@parthbyt I'm thinking in add a code that when I get this error he run again, but with a diferent port. Example: running with port localhost:8080 --> ERR_CONNECTION_REFUSED --> Try again with localhost:8081

parthbyt commented 4 years ago

@OuthBack This may work sometimes, but in few cases both the ports may result ERR_CONNECTION_REFUSED.

Like so running with port localhost:8080 --> ERR_CONNECTION_REFUSED --> Try again with localhost:8081 --> ERR_CONNECTION_REFUSED

samuelhwilliams commented 4 years ago

@OuthBack thanks for the video - can you confirm which version of Eel you're using?

This looks related to Eel's shutdown detection mechanism, whereby when any websocket closes, it waits 1 second, and then checks if there are now any websocket connections. If not, then Eel closes, thinking that the user has closed the browser and wants to exit the program. In your video you're spamming refresh, which I suspect is preventing any new websocket being established for the full second, and therefore Eel is just closing down.

I think we might want to make the shutdown timer configurable so that you could increase it, meaning there are more chances for the connection to be re-established before Eel shuts down. I'd be a little reluctant to disable this altogether as then it's possibly/likely that Eel would just end up staying alive forever, which feels more confusing as - if configured with a specific port - re-launching the app would error out.

OuthBack commented 4 years ago

image Version 0.14.0 Nice explanation!

arunsybex commented 3 years ago

@OuthBack @WMoraes13 @parthbyt

Just copy eel.js file into local webapp dir and replace _host: window.location.origin, into your custom IP like below

_host: "http://localhost:8000"

This works for me :100:

alexisthual commented 3 years ago

@OuthBack thanks for the video - can you confirm which version of Eel you're using?

This looks related to Eel's shutdown detection mechanism, whereby when any websocket closes, it waits 1 second, and then checks if there are now any websocket connections. If not, then Eel closes, thinking that the user has closed the browser and wants to exit the program. In your video you're spamming refresh, which I suspect is preventing any new websocket being established for the full second, and therefore Eel is just closing down.

I think we might want to make the shutdown timer configurable so that you could increase it, meaning there are more chances for the connection to be re-established before Eel shuts down. I'd be a little reluctant to disable this altogether as then it's possibly/likely that Eel would just end up staying alive forever, which feels more confusing as - if configured with a specific port - re-launching the app would error out.

@samuelhwilliams Why do we want this shutdown mechanism in the first place? I think I am looking for a way to have an eel server run all the time and enable several clients to connect to it. Is there a way to achieve this now and is it agains this project's philosophy?