Is RootBrowse Automatically Closing a Feature or a Bug?

Hello everyone,

I’ve been using Microsoft’s Edge browser to access RBrowse, and it generally works fine. However, I noticed that when I switch tabs, the RBrowse tab closes automatically after a short while (about 2-5 min). I suspect this might be related to the browser’s energy-saving features. Could this be a feature or a bug?

Is there a way to address this issue? Perhaps implementing a mechanism where the client and server exchange signals every 60 seconds could prevent the browser from suspending the page.

I use the following code to launch RBrowse and listen on 0.0.0.0. It is then accessed via an Nginx reverse proxy.
Command:

ROOT::RWebWindowsManager::SetLoopbackMode(false); // listen 0.0.0.0
gROOT->SetWebDisplay("server:12345");
auto browser = new  ROOT::RBrowser();

Nginx:

location ~ ^/rootbrowse/(?<port>\d+)(?<rest>.*)$ {
    proxy_pass http://server_host:$port$rest$is_args$args;
    proxy_set_header Host $http_host;                                                                                       
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";                                                                                  
    proxy_set_header Accept-Encoding gzip; 
}   

I’m also not sure if this issue is caused by some data not being properly handled by the reverse proxy.

ROOT Version: /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.32.08/x86_64-almalinux9.4-gcc114-opt/bin/thisroot.sh
Platform: Almalinux 9.4
Compiler: pre-compiled binary

Thank you,
Xiao

Update:
Even after disabling the energy-saving option in Edge, the page still automatically closes after I switch to other tabs for a while.

Without proxies or any special configuration, just a “pure” Linux Mint and ROOT 6.32.10, I tested this, running root with root --web=on:

ROOT::RWebWindowsManager::SetLoopbackMode(false); // listen 0.0.0.0
gROOT->SetWebDisplay("server:12345");
auto browser = new  ROOT::RBrowser();

which gave me a local http address to open the RBrowser.

$  root --web=on
   ------------------------------------------------------------------
  | Welcome to ROOT 6.32.10                        https://root.cern |
  | (c) 1995-2024, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Feb 10 2025, 07:18:56                 |
  | From tags/v6-32-10@v6-32-10                                      |
  | With c++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0                   |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0] ROOT::RWebWindowsManager::SetLoopbackMode(false); // listen 0.0.0.0

WARNING!
Disabling loopback mode may leads to security problem.
See https://root.cern/about/security/ for more information.

root [1] gROOT->SetWebDisplay("server:12345");
root [2] auto browser = new  ROOT::RBrowser();
Info in <THttpEngine::Create>: Starting HTTP server on port 12345
New web window: http://localhost:12345/  (etc.)
root [3] auto browser = new  ROOT::RBrowser();
New web window: http://localhost:12345/  (etc.)

(I shortened the URLs above)
I tried first on Brave and then on Firefox (I first closed the tab in Brave, and then the link didn’t work --in the same session-- in Firefox, so I created the second RBrowser): I opened a random root file and plotted a leaf from it, switched to another tab on the web browser and then left the browser untouched for about 10 minutes, and I don’t see this issue, the tab still worked after returning to it. It could still be your browser (try something other than Edge) or something else in your setup (proxy, nginx); maybe just try as I did, in a simpler setup, to try to exclude some possibilities.

@linev could you have a look here?

Hi Xiao,

Behavior is not normal. Web browser tab should not be closing.

Every ROOT web window regularly (approx every 10 seconds) sends “keep alive” requests to ensure that connection between ROOT application and web browser remains.

Does Edge browser closes if RBrowser page remains active?

Regards,
Sergey

Hi Linev,

Thank you very much for your response. If the page remains active, it doesn’t automatically close.

I believe this issue is related to my complex operations. Every 10 seconds, I execute browser->GetWindowUrl(true) to get a new key. As a result, the link I click on isn’t up-to-date after 10 seconds, using an outdated key. I’m unsure if this is why the “keep alive” signal might not be sent correctly.

This is what confuses me. Ideally, I want RootBrowse to function as a server that I can open directly via a URL each time, without having to run a root command first. To achieve this, I update the key frequently in the background (browser->GetWindowUrl(true)) to ensure the link is always available. Is there a better approach? For example, is there a method to check if the key from the previous URL has expired?

By the way,

Behavior is not normal.

I think that this behavior (browser’s tab close automatically) is normal. When you use browser->GetWindowUrl(true) to obtain a new key and open a new link, the old tab automatically closes.

Best regards,
Xiao

Hi dastudillo,

Thank you very much for your response.

I believe this issue is related to my complex operations. And I’m attempting to test this in the most straightforward way possible.

Hi Xiao,

Yes, this how it should work. Once new key is used for connection, old key is deprecated and no longer valid. Client using such key will close browser window.

Use of complex keys done only because of security reasons.
Keys are used to create hash values for any message send between server and client.

If you sure that your network configuration secure, you can do following.
First of all, run ROOT with the command root --web=server:7788 to get fixed http address.
And then in ROOT session you can disable keys usage before starting TBrowser:

root [0] ROOT::RWebWindowsManager::SetUseSessionKey(false);
root [1] ROOT::RWebWindowsManager::SetUseConnectionKey(false);
root [2] new TBrowser

In such case browser always can be accessed via url http://localhost:7788/win1/.

If you working on remote machine - I recommend to use rootssh script which configure all necessary tunnels automatically. Please read short documentation.

Regards,
Sergey