luc-github / ESP3D

FW for ESP8266/ESP8285/ESP32 used with 3D printer
GNU General Public License v3.0
1.78k stars 466 forks source link

Internet access error #853

Closed Stephano2000 closed 1 year ago

Stephano2000 commented 1 year ago

Hi, In order to provide remote internet access to the ESP3D UI, i forwarded ports 80 and 81 to a public server server:10554 and server:10555 respectively. However the UI keeps disconnecting with a websocket error after 1 or 2 seconds. Accessing ESP3D locally works fine. I am not sure whether this is a bug or i am just not doing the correct port forwarding, noting that ports 80 and 81 are not available on the public server.

github-actions[bot] commented 1 year ago

Thank your for submiting, please be sure you followed template or your issue may be dismissed. if you deleted the template it is here

luc-github commented 1 year ago

yes this is due to a workaround for apple captive portal, it use local ip for websocket instead of document.location.host provided in address bar It is an issue I forget to handle orz... I need to think about it

luc-github commented 1 year ago

well actually I use ws://${document.location.hostname}:${connectionSettings.current.WebSocketPort}${path} so my assumption is wrong it was already fixed

can you check the dev tool of your browser to see what url is used and what is the error ? it could be due to antivirus / antispam software as you are no more on local area

Stephano2000 commented 1 year ago

It seems it's still after port 81: "Firefox can’t establish a connection to the server at ws://45.33.36.41:81/." Where can i modify the 81 in source code to test? I could make it 10555 to just check if the bug shows up or not.

luc-github commented 1 year ago

ok so check what could block on your computer, disable antivirus , firewall to check which is the blocking point

Stephano2000 commented 1 year ago

Antivirus and firewall are not in the picture. Why would the web browser try to open the websocket at port 81 while the base port is 10554?

luc-github commented 1 year ago

webui websocket use 81, it use webserver port +1 defaut webserver port is 80, so webui websocket use 80+1

luc-github commented 1 year ago

I did not handled you change websocket port, for nat so issue is there

luc-github commented 1 year ago

I will push a solution later tonight, I am out now

Stephano2000 commented 1 year ago

I changed the HTTP protocol port to 10554 in the UI, forwarded ports 10554 and 10554 to 10554 and 10555 respectively, and there are no disconnections anymore. So the browser itself should set the websocket port to the HTTP host port + 1 so that the websocket connection is successful.

luc-github commented 1 year ago

yes because you use same as used by FW you can have a look by just typing [ESP800] in web ui terminal, it will show the webui websocket port

Stephano2000 commented 1 year ago

Maybe I didn't explain myself clearly, or misunderstood your statement. What I meant was that the Web UI javascript/code should be modified so that it attempts to open (HTTP request port)+1 instead of relying on the port number communicated by ESP3D.

I have gone through the ESP3D code which led me to check out both [ESP400] and [ESP800]

luc-github commented 1 year ago

yes as I wrote I did not handled the case user change the port by nat - it currently use the port provided by [ESP800] - I will fix it in web UI by collecting current http port and add +1 to it to make the webui websocket port

luc-github commented 1 year ago

can you test this one and feedback ? index.html.gz

Stephano2000 commented 1 year ago

It bricked the UI. The UI flashed "connecting" for a fraction of a second then shows a continuously spinning arc. What was the force upload url (in the hope that it works to avoid a reflash)?

luc-github commented 1 year ago

arg you tested in local with port 80 not remote, I missed this case orz I fixed in this one index.html.gz Sorry ...

luc-github commented 1 year ago

use http://your ip?forcefallback=yes to update because ui is broken

Stephano2000 commented 1 year ago

arg you tested in local with port 80 not remote, I missed this case orz I fixed in this one index.html.gz Sorry ...

I can confirm that this one doesn't disconnect both locally, and remotely with forwarded ports. Thanks

luc-github commented 1 year ago

Cool, thank you for the feedback - I need to update the test server and do a rebuild for all target and update some docs It will be done tomorrow - here it is almost 23h and doing now is recipe to trouble / mistake, I did enough for tonight ;)

liqijian101 commented 1 year ago

Can HTTPS be supported

luc-github commented 1 year ago

current esp32 arduino webserver does not have this feature, it is planned as far I know

liqijian101 commented 1 year ago

The webpage displays "Webdevsocket connection error"

luc-github commented 1 year ago

@liqijian101 as issue here is confirmed resolved by OP- your issue is different - so please open new issue for your problem with full reproduction steps

luc-github commented 1 year ago

@Stephano2000 fixed in latest webui (a29), thank you for raising it

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.