Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SUGGESTION] Add feature to keep instance running if the webpage is still open #402

Open
Exitium-DEV opened this issue Sep 14, 2024 · 4 comments
Labels
enhancement New feature or request reverse-proxy Reverse proxy integration related issue

Comments

@Exitium-DEV
Copy link

Could we please get an option to not start the countdown until after the user has closed the tab?

I have a sandbox container running coder/code-server to allow remote development. With a 1m timeout, the container gets destroyed as I didn't navigate to another page.

I propose you to do this using WebSockets, as the close() event would fire once the tab is closed, as the websocket connection is destroyed.

So, the config option I propose is openTabsMaintainSession: true
With this set to true, when you connect to Sablier, it upgrades your connection to a socket connection; it pauses the countdown timer, and unpauses the timer once the close() event fires.

I'm not proficient in GoLang so I can't do a PR for this myself I'm sorry!

@Exitium-DEV Exitium-DEV added the bug Something isn't working label Sep 14, 2024
@Exitium-DEV
Copy link
Author

Ah wrong label sorry, it won't let me change it now

@acouvreur
Copy link
Member

I don't think it's possible to inject a websocket connection inside your webpage.

However, we could create a specific endpoint on Sablier directly, which you could connect from your website.

But this require being able to alter the source code of the webpage.

You could do that, or we could also consider a browser extension.

What do you think?

@Exitium-DEV
Copy link
Author

I don't think it's possible to inject a websocket connection inside your webpage.

However, we could create a specific endpoint on Sablier directly, which you could connect from your website.

But this require being able to alter the source code of the webpage.

You could do that, or we could also consider a browser extension.

What do you think?

The issue is I don't have access to alter the source. (Well I do, but it's a container)
It should be entirely possible if Sablier is acting as a proxy; you'd just upgrade the existing HTTP request.

If Sablier stops acting as a proxy then I can see the issue; however my understanding is that Trafik proxies to Sablier which proxies to the container

Essentially, the existing HTTP server that you use as the landing page, it just needs to pass the headers to upgrade to a WS connection (there may be a helper function in Go); at this point nothing else changes, except that the connection will stay alive and you can just listen to the socket closing

@acouvreur acouvreur added enhancement New feature or request reverse-proxy Reverse proxy integration related issue and removed bug Something isn't working labels Sep 21, 2024
@acouvreur
Copy link
Member

Essentially, the existing HTTP server that you use as the landing page, it just needs to pass the headers to upgrade to a WS connection (there may be a helper function in Go); at this point nothing else changes, except that the connection will stay alive and you can just listen to the socket closing

I need to try this out, this seems "hacky" but that could work I guess?

If you can provide some kind of proof of concept that'd be amazing.

No need to connect with Sablier whatsoever, just a simple auto upgrade to websocket or something else.


To be fair, I doubt this is technically doable ? How one request would upgrade to websocket but still serve content ?

Without an websocket client on the client side, the websocket switching protocol response will just be dropped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request reverse-proxy Reverse proxy integration related issue
Projects
None yet
Development

No branches or pull requests

2 participants