s00500 / ESPUI

A simple web user interface library for ESP32 and ESP8266
https://valencia.lbsfilm.at/midterm-presentation/
Other
932 stars 174 forks source link

fix websocket connection when using an alternate port #276

Closed d-a-v closed 11 months ago

d-a-v commented 11 months ago

This PR aims at fixing #275 in which there seems to be a misunderstanding.

This PR reverts this change (highlighted part).

To describe the problem, on esp8266 and regular espasync libraries, and this port-changing patch applied to the gui example:

-    ESPUI.begin("ESPUI Control");
+    ESPUI.begin("ESPUI Control", nullptr, nullptr, 2000);

Webserver is answering on port 2000 (http://10.0.1.165:2000/ => page loads) but displays Control Offline because javascript cannot connect back to esp through websocket: [R.] means reset (="connection refused"), nobody is answering:

17:32:44.067047 IP 10.0.1.137.38186 > 10.0.1.165.80: Flags [S], seq 2916582948, win 64240, options [mss 1460,sackOK,TS val 3719040969 ecr 0,nop,wscale 7], length 0
17:32:44.068908 IP 10.0.1.165.80 > 10.0.1.137.38186: Flags [R.], seq 0, ack 2916582949, win 24584, length 0

(10.0.1.137 is PC-webbrowser trying to reach ESP on port 80 but ESP is listening on port 2000) (web browser console: WebbSocket connection to 'ws://10.0.1.165/ws' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED)

With this proposed change, it simply works as before (like with the revert above).

~This PR is of course incomplete and~ I ran my tests with this before compiling:

cd tools; ./prepare_static_ui_sources.py -a

fixes #275

d-a-v commented 11 months ago

closing in favour of #277