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

**URL:** https://openvidu.discourse.group/t/websocket-connection-to-wss-mydomain-openvidu-failed-error-during-websocket-handshake-unexpected-response-code-400/710
**Category:** Issues with deployment
**Tags:** v2
**Created:** [May 6, 2020, 9:13am UTC](https://openvidu.discourse.group/t/websocket-connection-to-wss-mydomain-openvidu-failed-error-during-websocket-handshake-unexpected-response-code-400/710 "2020-05-06T09:13:30Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![matkonstant](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/matkonstant/32/384_2.png) [@matkonstant](https://openvidu.discourse.group/u/matkonstant)
#### Post date: [May 6, 2020, 9:13am UTC](https://openvidu.discourse.group/t/websocket-connection-to-wss-mydomain-openvidu-failed-error-during-websocket-handshake-unexpected-response-code-400/710/1 "2020-05-06T09:13:30Z")

</div>

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/](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](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?

 ![Clip2net_200506120814](https://global.discourse-cdn.com/free1/uploads/openvidu/original/1X/9233e64f7b2a1129ba75faff6e73212af26c3279.png)

---

<div class="post-metadata">

### Author: ![matkonstant](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/matkonstant/32/384_2.png) [@matkonstant](https://openvidu.discourse.group/u/matkonstant)
#### Post date: [May 6, 2020, 9:15am UTC](https://openvidu.discourse.group/t/websocket-connection-to-wss-mydomain-openvidu-failed-error-during-websocket-handshake-unexpected-response-code-400/710/2 "2020-05-06T09:15:20Z")

</div>

Here is more info from Network

 ![Clip2net_200506121622](https://global.discourse-cdn.com/free1/uploads/openvidu/original/1X/ff6aa4e5221bec78e51aa74bed208fac8bab9a09.png)

---

<div class="post-metadata">

### Author: ![micael.gallego](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/micael.gallego/32/2_2.png) [@micael.gallego](https://openvidu.discourse.group/u/micael.gallego)
#### Post date: [May 6, 2020, 12:15pm UTC](https://openvidu.discourse.group/t/websocket-connection-to-wss-mydomain-openvidu-failed-error-during-websocket-handshake-unexpected-response-code-400/710/3 "2020-05-06T12:15:20Z")

</div>

Please use the same version from client and server.

---

<div class="post-metadata">

### Author: ![matkonstant](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/matkonstant/32/384_2.png) [@matkonstant](https://openvidu.discourse.group/u/matkonstant)
#### Post date: [May 6, 2020, 12:36pm UTC](https://openvidu.discourse.group/t/websocket-connection-to-wss-mydomain-openvidu-failed-error-during-websocket-handshake-unexpected-response-code-400/710/4 "2020-05-06T12:36:59Z")

</div>

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](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

---

<div class="post-metadata">

### Author: ![micael.gallego](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/micael.gallego/32/2_2.png) [@micael.gallego](https://openvidu.discourse.group/u/micael.gallego)
#### Post date: [May 7, 2020, 2:16am UTC](https://openvidu.discourse.group/t/websocket-connection-to-wss-mydomain-openvidu-failed-error-during-websocket-handshake-unexpected-response-code-400/710/5 "2020-05-07T02:16:23Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![matkonstant](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/matkonstant/32/384_2.png) [@matkonstant](https://openvidu.discourse.group/u/matkonstant)
#### Post date: [May 7, 2020, 7:54am UTC](https://openvidu.discourse.group/t/websocket-connection-to-wss-mydomain-openvidu-failed-error-during-websocket-handshake-unexpected-response-code-400/710/6 "2020-05-07T07:54:50Z")

</div>

I did the installation step by step according to the instructions here - [https://docs.openvidu.io/en/2.13.0/deployment/deploying-on-premises/](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](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

---

<div class="post-metadata">

### Author: ![micael.gallego](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/micael.gallego/32/2_2.png) [@micael.gallego](https://openvidu.discourse.group/u/micael.gallego)
#### Post date: [May 8, 2020, 11:19am UTC](https://openvidu.discourse.group/t/websocket-connection-to-wss-mydomain-openvidu-failed-error-during-websocket-handshake-unexpected-response-code-400/710/7 "2020-05-08T11:19:03Z")

</div>

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

To know if some of your changes caused the issue.

---

<div class="post-metadata">

### Author: ![matkonstant](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/matkonstant/32/384_2.png) [@matkonstant](https://openvidu.discourse.group/u/matkonstant)
#### Post date: [May 11, 2020, 8:51am UTC](https://openvidu.discourse.group/t/websocket-connection-to-wss-mydomain-openvidu-failed-error-during-websocket-handshake-unexpected-response-code-400/710/8 "2020-05-11T08:51:43Z")

</div>

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

---

<div class="post-metadata">

### Author: ![micael.gallego](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/micael.gallego/32/2_2.png) [@micael.gallego](https://openvidu.discourse.group/u/micael.gallego)
#### Post date: [May 11, 2020, 9:11am UTC](https://openvidu.discourse.group/t/websocket-connection-to-wss-mydomain-openvidu-failed-error-during-websocket-handshake-unexpected-response-code-400/710/9 "2020-05-11T09:11:32Z")

</div>

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

Can you show nginx and openvidu server logs please?

Regards

---

<div class="post-metadata">

### Author: ![matkonstant](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/matkonstant/32/384_2.png) [@matkonstant](https://openvidu.discourse.group/u/matkonstant)
#### Post date: [May 11, 2020, 9:17am UTC](https://openvidu.discourse.group/t/websocket-connection-to-wss-mydomain-openvidu-failed-error-during-websocket-handshake-unexpected-response-code-400/710/10 "2020-05-11T09:17:19Z")

</div>

nginx

Attaching to openvidu\_nginx\_1  
nginx\_1 | Domain name: [domain.ru](http://domain.ru)  
nginx\_1 | Certificated: owncert  
nginx\_1 | Letsencrypt Email: [user@example.com](mailto: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/](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/](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

---

<div class="post-metadata">

### Author: ![micael.gallego](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/micael.gallego/32/2_2.png) [@micael.gallego](https://openvidu.discourse.group/u/micael.gallego)
#### Post date: [May 13, 2020, 10:22am UTC](https://openvidu.discourse.group/t/websocket-connection-to-wss-mydomain-openvidu-failed-error-during-websocket-handshake-unexpected-response-code-400/710/11 "2020-05-13T10:22:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![matkonstant](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/matkonstant/32/384_2.png) [@matkonstant](https://openvidu.discourse.group/u/matkonstant)
#### Post date: [May 14, 2020, 8:58am UTC](https://openvidu.discourse.group/t/websocket-connection-to-wss-mydomain-openvidu-failed-error-during-websocket-handshake-unexpected-response-code-400/710/12 "2020-05-14T08:58:23Z")

</div>

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";
    }
    ...
}
```

---

<div class="post-metadata">

### Author: ![micael.gallego](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/micael.gallego/32/2_2.png) [@micael.gallego](https://openvidu.discourse.group/u/micael.gallego)
#### Post date: [May 14, 2020, 9:10am UTC](https://openvidu.discourse.group/t/websocket-connection-to-wss-mydomain-openvidu-failed-error-during-websocket-handshake-unexpected-response-code-400/710/13 "2020-05-14T09:10:07Z")

</div>

Perfect.

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