question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tunnel is disconnected almost immediately

See original GitHub issue

Hi Folks,

First, let me start with big kudos for the solution!

I’d like to make it as self-hosting solution, but unfortunately even though I followed the readme I was not able to succeed.

The problem I’ve encountered is that server is running and accepting incoming connections but dropping them almost immediately.

On server side I have a linux box with ubuntu server. I’ve tried both dockerized version and “standard” one. My run command is node -r esm ./bin/server --port 3000 --domain tun.sub.domain.com --secure true // exact name has been changed to tun.sub.domain.com //

Added some log.debug’s and on the server side I got:

localtun_1  | [debug]   server listening on port: 3000
localtun_1  | [debug]   undefined
localtun_1  | [debug]   tcp server listening on port: 42405
localtun_1  | [debug]   removing client: mighty-skunk-48
localtun_1  | [debug]   closed tcp socket
localtun_1  | [debug]   closed tcp socket
localtun_1  | [debug]   server listening on port: 3000
localtun_1  | [debug]   undefined
localtun_1  | [debug]   tcp server listening on port: 46035
localtun_1  | [debug]   removing client: helpless-cougar-46
localtun_1  | [debug]   closed tcp socket
localtun_1  | [debug]   closed tcp socket


While on the client side // I have it behind nginx listening with SSL on port 3333 (config from your repo localtunnel-nginx) that’s why you see port 3333 on client side

 ✘  npx localtunnel --port 8000 --host https://tun.sub.domain.com:3333                         
your url is: https://mighty-skunk-48.tun.sub.domain.com:3333

but no traffic and /api/status reply with {tunnels:0...}

 ✘  npx localtunnel --port 8000 --host https://tun.sub.domain.com:3333                         
your url is: https://helpless-cougar-46.tun.sub.domain.com:3333

but no traffic and /api/status reply with {tunnels:0...}

Actually I’ve discovered that if I hit /api/status fast enough I got reply with {tunnels:1...} for a friction of a second.

Any ideas what’s wrong here? Thanks a lot!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
rohanpooniwalacommented, Nov 15, 2021

I had a similar issue. Turns out I had to open all the ports for my server in the network firewall as Client tries to connect to assigned port on the go.

I hope this helps!

0reactions
smashahcommented, Sep 6, 2022

Ok wow it turns out someone did think of this and somehow implemented it half way.

Step 1.

Change ./lib/server.js

add the ip flag:

    .options('ip', {
        default: undefined,
        describe: 'IP address to inform to client'
    })

&

const server = CreateServer({
    max_tcp_sockets: argv['max-sockets'],
    secure: argv.secure,
    domain: argv.domain,
    ip: argv.ip, // <<add this line
});

Step 2.

Change ./server.js in the same location as above

        const url = schema + '://' + info.id + '.' + opt.domain || ctx.request.host;
        info.url = url;
        info.ip = opt.ip; // <<<<< add this line
        ctx.body = info;
        return;

Then make sure to add your explicit ip address with the --address flag:

> lt --host https://my.tunnel.cloud --port 3000 -s dumberror --ip 123.123.123.123

That’s it. Now it will work as expected. smh.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VPN Keeps Disconnecting? Here's the Solution (100% Works)
Fix Your VPN Connection Quickly and Easily. It might seem daunting but more often than not, fixing your VPN is a simple procedure...
Read more >
Packet Tunnel Provider can't conne… | Apple Developer Forums
Here we have our problem: immediately in system wake callback(NSWorkspace.didWakeNotification), activation of tunnel fails almost always.
Read more >
Solved: SSL VPN Disconnect Issue - DevCentral
Hi, Are you running full tunnels or split tunnels?. We had a similar problem with split tunnels, some clients would disconnect after 10...
Read more >
7 Reasons Your VPN Keeps Disconnecting (And How to Fix It)
1. Your Connection Has Too Much Latency ... VPN software creates an encrypted 'tunnel' between your device and a remote VPN server. Every...
Read more >
Red15 disconnects after establishing RDP connection
From yesterday one of the tunnels disconnects immediately after someone ... This branch was worked fine almost a year without any problems.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found