Church
Church

Reputation: 63

Laravel rest api - calling SSE or Long polling blocks other HTTP request

I'm working on a Laravel + Vue SPA with a comment module for a ticketing system (helpdesk), aiming to implement real-time comments. I've successfully implemented an SSE with a while loop. However, an issue arises when the SSE is open, and I try to make a new HTTP request — the new request seems to freeze and never completes due to the active SSE connection.

How to avoid this problem?

Than you

Able to request HTTP while SSE is open

Upvotes: 1

Views: 114

Answers (1)

Abdullah
Abdullah

Reputation: 13

I've stumped upon the same issue , and figured out why .

This issue occurs because Laravel uses a single-threaded request-handling model (in most configurations), meaning that while the SSE endpoint is running and keeping the connection open, Laravel cannot handle other incoming requests. The result is that requests are effectively "blocked" until the SSE process completes.

So basically you have to use Websocket , because it uses a different protocol WS which won't block the HTTP requests that Laravel uses .

Upvotes: 0

Related Questions