Angular proxy can't handle two parallel calls to the same path

437 views Asked by At

I have an angular-application that consumer a SSE-Stream from my Java Spring Backend. The problem occurs when I try to make REST-calls to that same path.

So I have code like this (simplified):

let eventSource = new EventSource('/api/my-favorite-path');
eventSource.onmessage....

proxy.conf.json:

{
    "/api/*": {
    "target": "http://localhost:8888",
    "secure": false
    }
}

Now when I try to do this somewhere else:

httpClient.get('/api/my-favorite-path')

The call never finishes and loads forever. My eventSource works without problems otherwise and subscribes correctly etc. and I can also make REST-calls to other paths that are correctly routed through the angular proxy but having a sse-call (which never finishes) and then doing another REST-call before it finishes doesn't seem possible to the same path.

Does anyone have a tip for me how I can still test this locally?

1

There are 1 answers

0
Juliette On

I found the problem: It hat nothing to do with the angular proxy and was instead caused by the browser limit of maximum 5 concurrent http-connections -> meaning when I opened too many SSE-connections that limit was reached and all further calls are blocked.

Using just one sse-connection that contains the "topic"/"stream" instead of multiple connections for each event-types solved the problem. If more that 5 tabs are open in the same browser it will break again though