I am using the SSE emitter to transfer notification events for the spring boot back-end to the the angular front-end. My problem is that this works fine locally on my PC, but no when deploying on a server, the front end doesn't receive anything and keeps hanging. There errors appears on console: enter image description here But in the network the response has status 200 but his content is empty. These my backend code:
@RequestMapping(path = "/public/stream", method = RequestMethod.GET)
public SseEmitter stream() {
SseEmitter emitter = new SseEmitter((long) (60000 * 5));
ExecutorService sseMvcExecutor = Executors.newSingleThreadExecutor();
sseMvcExecutor.execute(() -> {
emitters.add(emitter);
emitter.onCompletion(() -> {
emitters.remove(emitter);
});
});
return emitter;
}
These my fronted code (listener):
source!: EventSource;
// listener backend for getting value of progress from compressing
connectStream(): void {
this.source = new EventSource(environment.api_url + '/stream');
this.source.addEventListener('message', message => {
this.progressResource = message.data;
});
}
As I said before, locally all works fine, only in production I get this error. Hope someone help me! Thx