server: 408 error after about a minute of working
I am hosting the local tunnel server in an AWS ec2 instance, after setting up everything when, I try to connect from the client, the tunnel works for about a minute then shows HTTP ERROR 408.
site.conf from nginx/conf.d:
proxy_http_version 1.1;
server {
listen 0.0.0.0:80;
location / {
proxy_pass http://127.0.0.1:3000/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto http;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_redirect off;
}
}
nginx.conf:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log off;
sendfile on;
#tcp_nopush on;
gzip on;
gzip_min_length 1000;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites/*;
}
why does it work just for about a minute. I tried it from both CLI and API.
About this issue
- Original URL
- State: open
- Created 10 months ago
- Comments: 27
After non stop debugging and testing the whole day and night, I (hopefully) found a solution. At least it works locally and has nothing todo with localhost / 127.0.0.1
This simple line in
server/TunnelAgent.js
makes the magic happen:It ensures for some reason (didn’t look deeper into it for now) that the connection is getting reestablished after getting dropped. Without this line an important other event (don’t know which one for now) is not getting fired which results in broken sockets (9+1 as defined by default).
Will try to implement these changes on my live server as soon as I got some sleep and hopefully it works there too.
Example:
Without this "fix":
With this "fix":
Tested on my VPS with success 🎉 Works with all versions of Node (16,18,20)
@tiagopazhs quick update after debugging the hell out of locatunnel and your repository of localTunnel-OpenSource:
I debugged the problem down to the
net.connect
since I figured out, that the local connection just drops with http error 408. The local connection which maps the local application to the client service.As I thought, the reason is this: https://github.com/nodejs/node/issues/43776
I used your
localTunnel-OpenSource
to debug since socket.io and express just gives me more details when running it withDEBUG=*
.Now I’ll try to implement the changes I’ve made into localtunnel… let’s see
Exactly,
18 | 18/20 | 18 | 127.0.0.1/locahost
is what we wanna get up and running. In fact - every time a user uses Node v18 or higher, localtunnel stops working after about 1 minute. I guess the socket connection just drops or something.I already tried to update all dependencies to its latest version - with the same result - getting HTTP ERROR 408 after some time and dropping connection when max socket connection is reached.
Also thought about using
socket.io
for connection but it’s not that easy to make it work. Reason therefore is, that this repository usessocket.io
(https://github.com/BenMcH/node-grok) and it simply works! But without a subdomain like localtunnel 😦Will try to replace koa with express like you mentioned, maybe this gives me some other responses or ideas.
Were you able to reproduce the error I mentioned with the 408 http error?