Scheduled task not working with websockets

This can be fixed by manually defining a TaskScheduler bean, see for example this post: https://medium.com/@jing.xue/spring-boot-application-startup-error-with-websocket-enabled-832456bb2e

So, in Java terms, this would be

@Bean
public TaskScheduler taskScheduler() {
    TaskScheduler scheduler = new ThreadPoolTaskScheduler();

    scheduler.setPoolSize(2);
    scheduler.setThreadNamePrefix("scheduled-task-");
    scheduler.setDaemon(true);

    return scheduler;
}

In addition to accepted answer from Michel:

When using Spring Boot, instead of creating TaskScheduler directly, it may be wiser to use a builder for it:

@Bean
public ThreadPoolTaskScheduler taskScheduler(TaskSchedulerBuilder builder) {
    return builder.build();
}

The builder is defined in org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration. So, using this approach you will get exactly the same scheduler as if you were not using @EnableWebSocket (i.e. it will use pool size from spring configuration properties, etc.).