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

How to stop the Agent #148

Open
sammachin opened this issue Jul 29, 2024 · 9 comments
Open

How to stop the Agent #148

sammachin opened this issue Jul 29, 2024 · 9 comments

Comments

@sammachin
Copy link

When I close a connection using either the listener.close() or the ngrok.disconnect(listener.url()) methods it does not close down the agent session, I can see the agent still active in my dashboard (with 0 tunnels)

This means that I am unable to start a new agent on another machine as I get the error:

Connect error: failed to connect session: Your account is limited to 1 simultaneous ngrok agent sessions.
You can run multiple simultaneous tunnels from a single agent session by defining the tunnels in your agent configuration file and starting them with the command `ngrok start --all`.
Read more about the agent configuration file: https://ngrok.com/docs/secure-tunnels/ngrok-agent/reference/config
You can view your current agent sessions in the dashboard:
https://dashboard.ngrok.com/tunnels/agents error_code: ERR_NGROK_108

According to the docs: The close method on a listener will shut it down, and also stop the ngrok session if it is no longer needed. But this does not seem to be working on either 1.0.0, or 1.3.0

@nikolay-ngrok
Copy link
Collaborator

Hello @sammachin, have you tried the kill function? Or ngrok.disconnect without any url? I'll investigate further why the session/agent is not closing when using the listener.

@sammachin
Copy link
Author

@nikolay-ngrok Hi, thanks for responding, tried both the ngrok.kill() and ngrok.disconnect() but they have the same effect the tunnel is stopped but not the agent.

@nikolay-ngrok
Copy link
Collaborator

Another option to try is to control the session explicitly - instead of using the listener factory methods, you could connect a session and later close it when you need? e.g. start with https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-http-minimum.js#L13 and then do https://ngrok.github.io/ngrok-javascript/classes/Session.html#close when you need it?

@sammachin
Copy link
Author

@nikolay-ngrok creating the session manually seems to work, but thats a lot of work to do in my code to refactor it for all the options that a user can set, any chance this can be fixed in the ngrok module so that at least kill() stops the agent.

@inconshreveable
Copy link

just dropping a note here that we're actively working through the design of the next api rev for our SDKs and this is one of the improvements we're going to work on incorporating into the design

@grawsom
Copy link

grawsom commented Aug 19, 2024

I then have an wish, if this is not in the pipe line.
It could be nice that when using ngrok website that the part with tunnel/agent stop / restart etc. would work with the agent.
Just a small wish. :-)

@sammachin
Copy link
Author

@inconshreveable Thanks Alan, what sort of timeframe are we looking at to update the SDK? I could refactor my library to control the session directly but thats not a small amount of work and I don't really want to invest my time if its going to be solved upstream as soon as I finish!

@inconshreveable
Copy link

@sammachin i can't commit to a timeline here but i'd say "no earlier than october"

@grawsom it sounds like you're asking for the SDK to close the session when you use the dashboard 'stop' function, yes?

@grawsom
Copy link

grawsom commented Aug 21, 2024

@inconshreveable I'm just a user and when I install the Ngrok the "normal" way i then have some control in the website.

https://dashboard.ngrok.com/tunnels/agents
image

How it would work in your code i don't know, i just know that you could not do this by @sammachin package that uses you code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants