I've noticed that clients subscribed to a Mercure hub don't automatically reconnect (as long as their session in the web application hasn't expired) if the Mercure server is down and running again. In the case of clients subscribed from Edge or Chrome if they automatically reconnect (as long as their session has not expired in the web application). The same thing happens when a user tries to generate a report, let's say in Excel or PDF, when the request to the server starts, the client disconnects from the Mercure hub, and for Mozilla users, the page must be reloaded to subscribe again, with other browsers the reconnection is automatic.
Is this behavior atypical in my case or is it already known!? I have Mozilla Firefox in its latest version on Windows 10.
Indeed, searching a bit on SO, other users explain that the behavior of browsers is not the same with the EventSource object, and in the case of Mozilla Firefox even up to the latest version, when a disconnection caused by the server occurs, the browser does not is able to "reconnect". My specific case causes the disconnections from the Mozilla two aspects:
connectiontimeout
ytimeout
of 60 seconds.In both cases, in other browsers, the reconnection is automatic, but not in Mozilla.
I found the solution in SO , and of all the proposals I stayed with the use of the ReconnectingEventSource script , replacing the EventoSource object with the mentioned one once the
script
previous one was included in the template:The rest of the code remains. This object
ReconectingEventSource
also supports a propertymax_retry_time
that I set to 60 seconds to keep the reconnect time based on the time that the Apache2 reverse proxy timeout sets. In this way the two problems that cause disconnection to the Mercure hub every xx time and that Mozilla is not able to restore are solved.