Working with spring reactive application, I created a rest service which produces an event every second. The code for my rest controller is:
@GetMapping(value = "/events", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<Event> getEvents() {
Flux<Event> eventFlux = Flux.fromStream(Stream.generate(() -> new Event(new Random().nextLong(), "Hello Event")));
Flux<Long> emmitFlux = Flux.interval(Duration.ofSeconds(1));
return Flux.zip(eventFlux, emmitFlux).map(Tuple2::getT1);
}
The application runs fine at the url: localhost:8080/events in the browser. I get a new event every second. But when I close the browser I get the following error:
java.io.IOException: An established connection was aborted by the software in your host machine
Have anyone faced and resolved any similar issue with spring-reactive?