vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
605 stars 166 forks source link

Do not connect directly to the Spring Boot livereload server #13646

Open Artur- opened 2 years ago

Artur- commented 2 years ago

Describe your motivation

When you start a Spring Boot application using Spring boot dev tools, it automatically starts a livereload server on port 35729. This port is hard coded so if you start two Spring Boot applications, you will have only one livereload server listening.

Flow connects directly to the port from the browser, so if you run two applications locally then both will connect to the same livereload server. Live reloading will work for one and not for the other.

Apparently also if you configure the server to use ssl then we try to use a secure websocket connection (wss://) for port 35729 but this does not work (#13632).

Describe the solution you'd like

Instead of connecting to the livereload server from the browser, we should use the same debug window connection we already have. On the server, we should listen to reload events from Spring Boot like the LiveReloadServer does: https://github.com/spring-projects/spring-boot/blob/fdb1010cbc75517f511d4ab82de7d8f0ee058849/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfiguration.java#L193-L198

When an event arrives, we send the "reload" command using the debug window connection and react as we do today.

Additional context

This will remove the need for one websocket connection and make livereload work even if you run multiple applications locally

Artur- commented 1 year ago

The problem with implementing this is that the dev tools ws connection is closed when the application is restarted and there is no way to send a message that the browser should reload when restart is complete