Watchdog kills webpack on Windows Terminal Server

I develop on a win terminal server (Windows Server 2012 R2 Datacenter).
I can’t run even either starter-project or Bookstore demo apps in developer mode.
In production mode everything is fine.

In dev mode I get error belowe:

2019-12-12 09:10:08.907  INFO 625716 --- [        webpack]
 dev-webpack                              : ←[38;5;35mi ?wds?: Project is running at http://localhost:59229/webpack-dev-server/←[0m
2019-12-12 09:10:08.910  INFO 625716 --- [        webpack]
 dev-webpack                              : ←[38;5;35mi ?wds?: webpack output is served from /VAADIN/←[0m
2019-12-12 09:10:08.911  INFO 625716 --- [        webpack]
 dev-webpack                              : ←[38;5;35mi ?wds?: Content not from webpack is served from C:\Users\toth\eclipse2019-workspace\my-starter-project\target\classes\META-INF\VAADIN, src/main/webapp←[0m
2019-12-12 09:10:08.914  INFO 625716 --- [        webpack]
 dev-webpack                              : ←[38;5;35mWatchdog connection error. Terminating webpack process...←[0m
2019-12-12 09:10:08.935 ERROR 625716 --- [  restartedMain]
 o.a.c.c.C.[Tomcat]
.[localhost]
.
[/]       : Exception sending context initialized event to listener instance of class [com.vaadin.flow.spring.
VaadinServletContextInitializer$DevModeServletContextListener]

java.lang.RuntimeException: Unable to initialize Vaadin DevModeHandler
        at com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener.contextInitialized(VaadinServletContextInitializer.java:322) ~[vaadin-spring-12.1.1.jar:na]

        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4683) ~[tomcat-embed-core-9.0.29.jar:9.0.29]

        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5146) ~[tomcat-embed-core-9.0.29.jar:9.0.29]

        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.29.jar:9.0.29]

With Jetty:

[WARNING]

javax.servlet.ServletException: java.lang.IllegalStateException: Webpack exited prematurely
    at com.vaadin.flow.server.startup.DevModeInitializer.initDevModeHandler (DevModeInitializer.java:338)
    at com.vaadin.flow.server.startup.DevModeInitializer.onStartup (DevModeInitializer.java:237)
    at org.eclipse.jetty.plus.annotation.ContainerInitializer.callStartup (ContainerInitializer.java:145)
    at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart (ServletContainerInitializersStarter.java:64)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:72)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext (ServletContextHandler.java:342)

How could I make it to work?

Watchdog tries to connect to the network TCP port opened by the Java dev server.
I may assume that something prevent watchdog from connecting to the port. May be firewall or something else.
DevModeHandler class uses debug log level to print the command which it uses to start the webpack dev server.
You may enable debug level logging and check which port is used by watchdog and check whether it’s available.

After debugging I’ve got this:

2019-12-18 16:41:24.351 DEBUG 824164 --- [  restartedMain]
 c.v.f.s.DevServerWatchDog$WatchDogServer : Watchdog server has started on port 65083
2019-12-18 16:41:26.229 DEBUG 824164 --- [  restartedMain]
 dev-webpack                              : Starting webpack-dev-server, port: 65084 dir: C:\Users\toth\eclipse2019-workspace\spring-demo
   c:\Install\nodejs\node.exe C:\Users\toth\eclipse2019-workspace\spring-demo\node_modules\webpack-dev-server\bin\webpack-dev-server.js --config C:\Users\toth\eclipse2019-workspace\spring-demo\webpack.config.js --port 65084 --watchDogPort=65083 -d --inline=false
2019-12-18 16:41:26.237  INFO 824164 --- [  restartedMain]
 dev-webpack                              : Waiting for webpack compilation before proceeding.
2019-12-18 16:41:28.586 DEBUG 824164 --- [        webpack]
 dev-webpack                              : e[38;5;35mi ?wds?: Project is running at http://localhost:65084/webpack-dev-server/e[0m
2019-12-18 16:41:28.587 DEBUG 824164 --- [        webpack]
 dev-webpack                              : e[38;5;35mi ?wds?: webpack output is served from /VAADIN/e[0m
2019-12-18 16:41:28.587 DEBUG 824164 --- [        webpack]
 dev-webpack                              : e[38;5;35mi ?wds?: Content not from webpack is served from C:\Users\toth\eclipse2019-workspace\spring-demo\target\classes\META-INF\VAADIN, src/main/webappe[0m
2019-12-18 16:41:28.589 DEBUG 824164 --- [        webpack]
 dev-webpack                              : e[38;5;35mWatchdog connection error. Terminating webpack process...e[0m
2019-12-18 16:41:28.603 ERROR 824164 --- [  restartedMain]
 o.a.c.c.C.[Tomcat]
.[localhost]
.
[/]       : Exception sending context initialized event to listener instance of class [com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener]


java.lang.RuntimeException: Unable to initialize Vaadin DevModeHandler
	at com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener.contextInitialized(VaadinServletContextInitializer.java:322) ~[vaadin-spring-12.1.1.jar:na]

	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4683) ~[tomcat-embed-core-9.0.24.jar:9.0.24]

	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5146) ~[tomcat-embed-core-9.0.24.jar:9.0.24]

	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.24.jar:9.0.24]


I wish I know how could I modify/set ‘Watchdog server’ and webpack-dev-server port and IP address. Some config file or whatever.
It isn’t goot that they wants to run on localhost and a freely chosen port; it will not work on a terminal server.

I recommend to check the possibility to connect to the watchdog port.
I’m not sure whether the app is still working for you after the exception.
But you may try to check whether the watchdog port which is written in the log is available (you may connect to it). E.g. you may try to connect to the port using telnet.

You may also change the default configuration.
If you open the webpack.config.js then you will see the line const flowDefaults = require('./webpack.generated.js'); . The webpack.generated.js file is autogenerated and it has no sense to change it. But you may copy webpack.generated.js to webpack.generated1.js e.g. and change the line in the webpack.config.js to include this file instead of webpack.generated.js.
Then just remove lines

if (watchDogPort){
    setupWatchDog();
}

from the copied file.
The watchdog won’t try to connect to the server port anymore.
That will disable the watchdog and you also may try to check whether the networks ports (webpack dev server and watchdog port) are working.
I think your system is blocking connection at least to watchdog port (and may be for other ports as well) via the firewall or some other way.