This article is a mirror article of machine translation, please click here to jump to the original article.

View: 2147|Reply: 0

[Other] SSE (2) fetch-event-source reconnection issue after switching browser tabs

[Copy link]
Posted on 2024-12-25 16:48:29 | | | |
Requirements: Use Microsoft's@microsoft/fetch-event-sourceAs a client of SSE, when the browser switches tabs, it will automatically disconnect from receiving messages, and then when the window is activated, it will reconnect to make requests and respond again.

Review:

SSE (1) uses ASP.NET Core as the SSE server
https://www.itsvse.com/thread-10752-1-1.html


Default behavior: Most browsers will automatically close the event source connection when the page becomes invisible when openWhenHidden is not specified. fetchEventSource automatically closes the request and reopens it when the document becomes visible again.



The hyperlink login is visible.

/**
     * If true, will keep the request open even if the document is hidden.
     * By default, fetchEventSource will close the request and reopen it
     * automatically when the document becomes visible again.
     */
    openWhenHidden?: boolean;


solution

openWhenHiddenSet to true will keep the request open even when the tab is hidden.






Previous:DNSPod resolves priority tests based on geography
Next:Angular 18 series (twenty-nine) checks if @Output's EventEmitter is bound
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com