flow icon indicating copy to clipboard operation
flow copied to clipboard

Do not connect directly to the Spring Boot livereload server

Open Artur- opened this issue 2 years ago • 0 comments

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- avatar Apr 28 '22 09:04 Artur-