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 is already in CLOSING or CLOSED state. #638

Open
olzii opened this issue Jan 13, 2022 · 14 comments
Open

WebSocket is already in CLOSING or CLOSED state. #638

olzii opened this issue Jan 13, 2022 · 14 comments

Comments

@olzii
Copy link

olzii commented Jan 13, 2022

Your environment.

  • Version: 8e1eaa5
  • Client: Vue.JS and "ion-sdk-js": "^1.7.2",
  • Environement: Ubuntu 20.04, Go version : go version go1.17.6 linux/amd64
  • Are you using a TURN server? Yes: stun:stun.l.google.com:19302

What did you do?

I was trying this example (Pion/Ion-Sfu One to Many) and deployed ION SFU and Vue example on real server.

What happened?

SFU and WebSocket is working without any problem about 1 minute and closing automatically.
And saying this error on browser console : 'WebSocket is already in CLOSING or CLOSED state.'
Screenshot 2022-01-13 213920

On server side, it has following log:
Screenshot 2022-01-13 214011
Screenshot 2022-01-13 214059

@yoon7t
Copy link

yoon7t commented Jan 14, 2022

me too.
image

@OrlandoCo
Copy link
Collaborator

@olzii are you using a reverse proxy for the websockets like nginx?, if so please make sure that the timeout is long enough or you need to handle gracefully the ws reconnec.

@olzii
Copy link
Author

olzii commented Jan 14, 2022

@olzii are you using a reverse proxy for the websockets like nginx?, if so please make sure that the timeout is long enough or you need to handle gracefully the ws reconnec.

Yes, i am using Nginx proxy. Default proxy timeout was 60 seconds, lets try to change it.

image

@olzii
Copy link
Author

olzii commented Jan 14, 2022

I have changed timeout to 310 seconds:

proxy_read_timeout 310s;

After 5 minute 10 seconds, it received Websocket closed error again.

@yoon7t
Copy link

yoon7t commented Jan 14, 2022

I have changed timeout to 310 seconds:

proxy_read_timeout 310s;

After 5 minute 10 seconds, it received Websocket closed error again.

nat1to1 is public ip?

@olzii
Copy link
Author

olzii commented Jan 14, 2022

Yes it is public ip.

Here is my Nginx proxy config :

location / {
        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-NginX-Proxy true;
        proxy_pass http://192.168.10.99:7000;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 310s;
    }

@yoon7t
Copy link

yoon7t commented Jan 14, 2022

Yes it is public ip.

Here is my Nginx proxy config :

location / {
        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-NginX-Proxy true;
        proxy_pass http://192.168.10.99:7000;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 310s;
    }

I shut it down because of the ICE problem. The solution is to change the value of configuration file NAT1to1 to public ip.Other reasons for the closure have not yet been encountered

@olzii
Copy link
Author

olzii commented Jan 14, 2022

@Y1nPengfei

My client and server using same ICE server

ION-SFU:
image
Vue:
image

Also i am using NAT1to1 config with my public IP.
image

@yoon7t
Copy link

yoon7t commented Jan 14, 2022

@y1n鹏飞

我的客户端和服务器使用相同的 ICE 服务器

ION-SFU: Vue: 图片 图片

我也在使用带有我的公共 IP 的 NAT1to1 配置。 图片

image
Try commenting out ICelite or setting it to false

@olzii
Copy link
Author

olzii commented Jan 14, 2022

@Y1nPengfei

Making "icelite=false" has no effect, result is same.

@olzii
Copy link
Author

olzii commented Jan 14, 2022

NGINX to reverse proxy websockets AND enable SSL

If i increase proxy_read_timeout value to 86400, it is working.
But i think it is not solving the issue, it just making timeout longer

@nkonev
Copy link
Contributor

nkonev commented Jan 14, 2022

offtop: I use traefik and I don't have any problems with websocket

@ahmed-adly-khalil
Copy link

I have the exact same issue, anyone found a solution? i'm using NGINX and Kubernetes + the connection is over https

@OrlandoCo
Copy link
Collaborator

The solution is simple, just increase the timeout or gracefully recover from websocket reconnect.

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

5 participants