Search code examples
javaspringserver-sideserver-sent-events

SseEmitter with proxy


I have an issue with SSE in my spring application.

When I run my code on my local environment it work perfectly.

But when I deploy my application on my server, I can't get a response from my SseController

here is my code

  @GetMapping("/api/sse/connect")
public SseEmitter getConnexion(){
    if(sseEmitters == null){
        sseEmitters = new ArrayList<>();
    }
    SseEmitter emitter = new SseEmitter();
    sseEmitters.add(emitter);
    emitter.onCompletion(() -> sseEmitters.remove(emitter));
    return emitter;
}

The problem is, when the application is on the server, the request for /api/sse/connect don't get any response from the server, but other controller which return values work

I thought it may be a proxy issue, but I can't find any information regarding this error

Hope you can help me !


Solution

  • Which proxy do you use? Some proxies need special configurations (content-length, headers, etc.) to support SSE and some don't (like the AWS load balancer (at least last year)).