• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Issue Websocket connection failing on Plesk server

imitev

New Pleskian
Server operating system version
Ubuntu 22.04.4
Plesk version and microupdate number
18.0.60
I'm setting up a server on Plesk with a React.js and Node.js application, containing a client and server side.

Below the socket in my client config file:

export const socket = io('wss://domain.name:3000', {reconnect: true, transports: [ 'websocket' ] });

And this is the setup on the server side:

JavaScript:
ServerConfig.port = 3000;



const server = this.app.listen(ServerConfig.port,  () =>  {

        console.log('Ready on port %d', server.address().port);

    }),

I'm 100% sure this configuration works as I've tested it locally, as well as it's being used on another server which doesn't use Plesk.

I've set up the domains for the client and server, and when I now open my client I get the error message:

main.js:75 WebSocket connection to 'wss://domain.name:3000/socket.io/?EIO=3&transport=websocket' failed:

I don't now where the configuration mistake lies, I've also tried almost everything in the nginx.conf files of both the subdomain and the config file in /etc/nginx/nginx.conf for example:

  • Added the location block in Plesk with the correct IP address and port:

NGINX:
location / {
    proxy_pass http://ip.address:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

  • Also tried this with a localhost IP, since both services run on the same server. (just on different subdomains and ports)
  • Create a custom nginx file with the following:
NGINX:
upstream websocket {
      ip_hash;
      server ip.address:3000 weight=5;
      keepalive 10;
}

NGINX:
server {
    listen ip.address:443;
    ssl_certificate /opt/psa/var/certificates/certificate;
    ssl_certificate_key /opt/psa/var/certificates/key;

    server_name domain.name service.domain.name;

    location / {
        proxy_pass http://websocket;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}


and included it in the /etc/nginx/nginx.conf file. For this option I got errors if tried to place in the Additional nginx directives regarding "upstream" and "server".

Nothing seems to work and I keep getting the same error. Any suggestions help!
 
I am not completely sure, but three things come to mind that might be worth checking.

1) Did you disable proxy mode for the domain in Plesk?
2) I believe that the connection wss://domain.name:3000 would require port 3000 to be opened on the firewall. Did you check if port 300 is open?
3) Which IP address is used here proxy_pass http://ip.address:3000;? This should be local (127.0.0.1), because otherwise the proxy requests are routed externally, which I think won't work.
 
Back
Top