cancel
Showing results for 
Search instead for 
Did you mean: 

Using SAP approuter with server-sent events

manuel_seeger
Explorer
0 Kudos

Dear colleagues, 

Has anyone managed to make SAP approuter work with server-sent events? 

https://www.npmjs.com/package/@sap/approuter

We are using approuter as the entry point for applications on BTP. Right now we are building a chat application which uses server-sent events for real time communication between client and server: 

https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events

However, it looks like approuter does not support this. Requests send to the backend destination with Accept: text/event-stream stay open, but no data/event is received back from the backend on those requests. 

The application works fine without approuter in front of it. It looks like approuter blocks those events, or possibly is waiting for the initiating request to finish before sending anything back to the client (which would render server-sent events useless). 

Now I have not found any documentation that says event streaming is not supported by approuter. Has anyone made it work? Is there a setting or combination of settings in approuter or the destination server that is required for server-sent events to work? 

Best regards,

Manuel

Accepted Solutions (1)

Accepted Solutions (1)

manuel_seeger
Explorer
0 Kudos

To anyone else finding this, I finally made it work. 

The problem is compression middleware used in approuter.

https://www.npmjs.com/package/@sap/approuter#compression-property

Since the SSE request doesn't have a content-length and does not complete, I suspect approuter is unable to decide whether to apply compression or not, and the requests hangs. If the connection is cleanly closed, all messages are being sent at once. 

To make it work, disable compression on your SSE requests. Ideally, your server sets the Cache: no-transform header directive. 

Answers (0)