How to resolve the error: "Could not open websocket connection: websocket: could not find connection header with token 'upgrade'"

How to resolve the error: "Could not open websocket connection: websocket: could not find connection header with token 'upgrade'"

AuthorFullName__c
Loren Yeung
articleNumber
000003779
ft:sourceType
Salesforce
FirstPublishedDate
2017-05-03T22:33:52Z
lastModifiedDate
2023-01-22T11:05:33Z
VersionNumber
5

You may see following error message in xray_server.log:

[2017/04/28 12:19:56 UTC] [EROR] (jfrog.com/xray/handlers/ws.WsHandler.ConnectWsServer:29) Could not open websocket connection: websocket: could not find connection header with token 'upgrade'

Although this will not affect the backend of Xray’s operations, you might encounter the following issues in the Xray UI:

  • The JFrog Xray database's download progress bar does not get updated (e.g. the progress bar stays in 1% even though it finishes in the backend)

  • log messages fail to show

The issue is seen when WebSocket requests are not passed correctly by a reverse proxy or a load balancer. The following instructions will help you to resolve this problem:

For Nginx:
Add following settings for NGINX:
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade

 

For Apache HTTPD:
Add following settings for Apache HTTPD:
RewriteEngine On
ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/

## UI and logs
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteRule /(.*)           ws://localhost:8000/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*)           http://localhost:8000/$1 [P,L]


For the AWS ELB’s Classic Load Balancer:
The problem will be due to Classic Load Balancer’s HTTP protocol not passing along WebSocket requests. As a workaround, you may use the TCP protocol. Alternatively, you may use Amazon's Application Load Balancer, which supports WebSocket.