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

websocket隔一段时间断开 #3

Open
shixueqiang opened this issue Jan 7, 2024 · 11 comments
Open

websocket隔一段时间断开 #3

shixueqiang opened this issue Jan 7, 2024 · 11 comments

Comments

@shixueqiang
Copy link

shixueqiang commented Jan 7, 2024

nginx反代docker部署的electerm,ssh连接上服务器后,过一会就自动断了,windows客户端版本没有这个问题,请问是缺什么配置吗?

@zxdong262
Copy link
Member

保活间隔时间设为0试试?

@shixueqiang
Copy link
Author

保活间隔时间设为0试试?

不行,不到一分钟就自动断开了

@zxdong262
Copy link
Member

可以发一下nginx配置吗,我试试

@shixueqiang
Copy link
Author

shixueqiang commented Jan 10, 2024

server {
listen [::]:80;
server_name xxx;
location / {
proxy_pass http://[::1]:8880/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
}
location /common/s {
proxy_pass http://[::1]:8880;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /terminals/ {
proxy_pass http://[::1]:8880;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /sftp/ {
proxy_pass http://[::1]:8880;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}

@zxdong262
Copy link
Member

zxdong262 commented Jan 10, 2024

upstream electerm {
  server 127.0.0.1:8880;
}

server {
  listen 80;
  server_name xxxxx;

  location / {
    proxy_pass http://electerm;
    proxy_buffering off;
    proxy_set_header        Host            $host;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_read_timeout 86400;  # 1 day timeout
    proxy_send_timeout 86400;  # 1 day timeout
  }
}

试试这样看看可以不?

@zxdong262
Copy link
Member

应该是这个问题,参考上面的设置

    proxy_read_timeout 86400;  # 1 day timeout
    proxy_send_timeout 86400;  # 1 day timeout

@shixueqiang
Copy link
Author

upstream electerm {
  server 127.0.0.1:8880;
}

server {
  listen 80;
  server_name xxxxx;

  location / {
    proxy_pass http://electerm;
    proxy_buffering off;
    proxy_set_header        Host            $host;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_read_timeout 86400;  # 1 day timeout
    proxy_send_timeout 86400;  # 1 day timeout
  }
}

试试这样看看可以不?

还是1分钟左右ssh就断了,我换个服务器试试,那个服务器是v6机器,还用frp转发到内网服务了

@shixueqiang
Copy link
Author

shixueqiang commented Jan 11, 2024

我换了一台有ipv4的公网机器,用docker启动,不用nginx反代,ip端口访问,连上ssh后,什么都不操作,大概等5分钟也会自动断开
docker run --init -d --restart=always -v /home/electerm-web-data:/home/electerm/data
-e "DB_PATH=/home/electerm/data"
-e "HOST=0.0.0.0"
-e "SERVER=http://ip:8082"
-e "SERVER_PASS=xxx"
-e "ENABLE_AUTH=1"
-p 8082:5577
zxdong262/electerm-web

@zxdong262
Copy link
Member

我换了一台有ipv4的公网机器,用docker启动,不用nginx反代,ip端口访问,连上ssh后,什么都不操作,大概等5分钟也会自动断开 docker run --init -d --restart=always -v /home/electerm-web-data:/home/electerm/data -e "DB_PATH=/home/electerm/data" -e "HOST=0.0.0.0" -e "SERVER=http://ip:8082" -e "SERVER_PASS=xxx" -e "ENABLE_AUTH=1" -p 8082:5577 zxdong262/electerm-web

我试了,几个小时也没有断,也许有网络波动?

@irfanMiral
Copy link

irfanMiral commented Jan 22, 2024

Can you try this;

Change this line
proxy_pass http://[::1]:8880/;

to
proxy_pass http://[::1]:8880;

I had same issue, it seems SERVER value should be;
https://HOST:PORT not https://HOST:PORT/
or this if you don't use ssl
http://HOST:PORT not http://HOST:PORT/

@125540947
Copy link

求一个搭建教程。。。官方的看不懂

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