WebSocket connection to 'wss://mydomain/openvidu' failed: Error during WebSocket handshake: Unexpected response code: 400

Hello!

Thanks for your job! It great!

When I try to install openvidu, version 2.13.0 for the server and 2.12.0 for the browser is installed. I see a warning in the console about version mismatch. Installation was performed according to the instructions https://docs.openvidu.io/en/2.13.0/deployment/deploying-on-premises/ ( curl https://s3-eu-west-1.amazonaws.com/aws.openvidu.io/install_openvidu_2.13.0.sh | bash )

I try to start the broadcast from the webcam, but I get connection errors via sockets.
WebSocket connection to ‘wss://my_domain/openvidu’ failed: Error during WebSocket handshake: Unexpected response code: 400

How can I fix this error?

Here is more info from Network

Please use the same version from client and server.

Thanks for the answer.

I don’t understand how to install version 2.13.0 for the browser in Docker.
All I did was install openVidu via curl with version 2.13.0 (curl https://s3-eu-west-1.amazonaws.com/aws.openvidu.io/install_openvidu_2.13.0.sh | bash)
After that, I configured the environment and ran the command ./openvidu start

Sorry, my fault. Ignore version mismatch warning.

Please share openvidu logs with us so we can take a look.

Have you followed deployment instructions as explained? do you have some kind of reverse proxy configured? It seem there are a problem with WebSockets (maybe related with reverse proxies). Are you using services like CloudFlare or similar?

Regards.

I did the installation step by step according to the instructions here - https://docs.openvidu.io/en/2.13.0/deployment/deploying-on-premises/
The installation was made on our own server

We have reverse proxy for websockets by nginx

location /openvidu {
    ssi on;
    proxy_pass http://ip-address:5443;
    include proxy_params;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header Host $host;
}

This is a link to logs:

https://drive.google.com/file/d/1sQOb0ktzazBQMi0DHIrAytN_DUdm4MLD/view?usp=sharing

For Redis change configuration in docker-compose to my own to change default port

in docker-compose.yml:

 redis:
    build: ./redis
    restart: always
    network_mode: host
    volumes:
        - ./redis/redis.conf:/usr/local/etc/redis/redis.conf

./redis/Dockerfile

FROM redis:5.0.7
COPY redis.conf /usr/local/etc/redis/redis.conf
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]

./redis/redis.conf

bind 0.0.0.0
protected-mode yes
port 6380
tcp-backlog 511
timeout 0
tcp-keepalive 300
#pidfile /var/run/redis/redis-server.pid
#loglevel notice
#logfile /data/log/redis-server.log
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
#dbfilename dump.rdb
#dir /data/bases
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
slave-lazy-flush no
appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble no
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

That’s all I changed

Can you test with a clean installation without any customization please?

To know if some of your changes caused the issue.

I tried to install it without any changes. The problem remains the same.

There may be problems with the ports, but all the ports from the documentation description have been opened.

I logs i see this:
[INFO] 2020-05-11 09:06:53,602 [0.0-5443-exec-2] io.openvidu.server.config.HttpHandshakeInterceptor - Old HttpSession 4F8C8732B1EF926988B2EF440AC5DF5C
[ERROR] 2020-05-11 09:06:53,602 [0.0-5443-exec-2] org.springframework.web.socket.server.support.DefaultHandshakeHandler - Handshake failed due to invalid Upgrade header: null

We can not see the logs. Have you attached them?

Can you show nginx and openvidu server logs please?

Regards

nginx

Attaching to openvidu_nginx_1
nginx_1 | Domain name: domain.ru
nginx_1 | Certificated: owncert
nginx_1 | Letsencrypt Email: user@example.com
nginx_1 | Proxy mode: CE
nginx_1 | Demos mode: true
nginx_1 | ===Mode owncert===
nginx_1 | Using owmcert…
nginx_1 | Restarting nginx: nginx.
nginx_1 | 192.168.0.26 - OPENVIDUAPP [11/May/2020:06:05:29 +0000] “POST /api/sessions HTTP/1.0” 200 39 “https://domain.ru/” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36” “94.25.239.21”
nginx_1 | 192.168.0.26 - OPENVIDUAPP [11/May/2020:06:05:30 +0000] “POST /api/tokens HTTP/1.0” 200 406 “https://domain.ru/” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36” “94.25.239.21”
nginx_1 | 192.168.0.26 - - [11/May/2020:06:05:30 +0000] “GET /openvidu HTTP/1.0” 400 34 “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36” “94.25.239.21”
nginx_1 | 192.168.0.26 - - [11/May/2020:06:05:30 +0000] “GET /openvidu HTTP/1.0” 400 34 “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36” “94.25.239.21”
nginx_1 | 192.168.0.26 - - [11/May/2020:06:05:34 +0000] “GET /openvidu HTTP/1.0” 400 34 “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36” “94.25.239.21”
nginx_1 | 192.168.0.26 - - [11/May/2020:06:05:37 +0000] “GET /openvidu HTTP/1.0” 400 34 “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36” “94.25.239.21”

Errors from openvidu
openvidu-server_1 | [ERROR] 2020-05-11 09:16:19,641 [0.0-5443-exec-5] org.springframework.web.socket.server.support.DefaultHandshakeHandler - Handshake failed due to invalid Upgrade header: null
openvidu-server_1 | [INFO] 2020-05-11 09:16:26,777 [0.0-5443-exec-8] io.openvidu.server.config.HttpHandshakeInterceptor - Old HttpSession 4F8C8732B1EF926988B2EF440AC5DF5C
openvidu-server_1 | [ERROR] 2020-05-11 09:16:26,778 [0.0-5443-exec-8] org.springframework.web.socket.server.support.DefaultHandshakeHandler - Handshake failed due to invalid Upgrade header: null
openvidu-server_1 | [INFO] 2020-05-11 09:16:30,957 [0.0-5443-exec-7] io.openvidu.server.config.HttpHandshakeInterceptor - Old HttpSession 4F8C8732B1EF926988B2EF440AC5DF5C
openvidu-server_1 | [ERROR] 2020-05-11 09:16:30,957 [0.0-5443-exec-7] org.springframework.web.socket.server.support.DefaultHandshakeHandler - Handshake failed due to invalid Upgrade header: null
openvidu-server_1 | [INFO] 2020-05-11 09:16:34,997 [0.0-5443-exec-9] io.openvidu.server.config.HttpHandshakeInterceptor - Old HttpSession 4F8C8732B1EF926988B2EF440AC5DF5C
openvidu-server_1 | [ERROR] 2020-05-11 09:16:34,998 [0.0-5443-exec-9] org.springframework.web.socket.server.support.DefaultHandshakeHandler - Handshake failed due to invalid Upgrade header: null
openvidu-server_1 | [INFO] 2020-05-11 09:16:39,022 [.0-5443-exec-10] io.openvidu.server.config.HttpHandshakeInterceptor - Old HttpSession 4F8C8732B1EF926988B2EF440AC5DF5C
openvidu-server_1 | [ERROR] 2020-05-11 09:16:39,022 [.0-5443-exec-10] org.springframework.web.socket.server.support.DefaultHandshakeHandler - Handshake failed due to invalid Upgrade header: null
openvidu-server_1 | [INFO] 2020-05-11 09:16:42,997 [0.0-5443-exec-1] io.openvidu.server.config.HttpHandshakeInterceptor - Old HttpSession 4F8C8732B1EF926988B2EF440AC5DF5C

We have improved several installation details in 2.14 version. Can you test with it?

We solved the issue with sockets for version 2.13 by configuring nginx

server {
    ...
    location / {
        proxy_pass https://our_ip_address;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
    }

    location /openvidu {
        proxy_pass https://our_ip_address;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }
    ...
}

Perfect.

OpenVidu comes with their own proxy to configure all these things for you automatically.