Open jonmchan opened 4 years ago
For anyone else experiencing this issue on their own localtunnel instance, I've written a hack to get it working for myself - a delete endpoint:
router.get('/api/tunnels/:id/delete', async (ctx, next) => {
const clientId = ctx.params.id;
const client = manager.getClient(clientId);
if (!client) {
ctx.throw(404);
return;
}
manager.removeClient(clientId);
ctx.body = {
delete_status: "success",
};
});
https://github.com/jonmchan/localtunnel-server/blob/delete-endpoint/server.js#L53-L65
This isn't ideal for a public instance of localtunnel as malicious users can kick someone off and steal their subdomain, but for a private instance of localtunnel, this works well instead of having my developers contact me to constantly restart the server.
Added pings in this fork https://github.com/StyleT/mytunnel-server so should be fixed now. However you need to use https://github.com/StyleT/mytunnel client to make it work.
If the localtunnel client is not properly closed, localtunnel may reserve an instance indefinitely and never close the connection. This can happen if wifi dies, internet connection dies, a computer was shut down improperly or set to sleep, or even by just suspending the process while it is running. Any of these scenarios can leave localtunnel server in a state where it is keeping the TunnelAgent sockets open and not allowing the subdomain to be reused.
Repro steps:
Disconnect wifi, kill the process, and reconnect to the internet.
Next time when you try to connect, the subdomain is no longer available.