WebSocket wss help

Good day. Please tell me the solution that will allow me to implement secure communication (wss) between the server and the client on the websockets. I use openfl-websocket to connect. Insecure connection (ws) to implement was not so difficult. But if the client is in the https zone, then there are difficulties connecting to the server. The fact is that I have a server located on vps hosting. The server is written in Java. Apache on vps is not used, there is only a running program in the form of a server. When I try to connect, I just get a timeout
WebSocket connection to ‘wss: // ip: port /’ failed: WebSocket opening handshake timed out. If you change to ws + go to the link on http, then everything works, but you need https. Tell me what should I do to make it work?

  1. What do I need to do on the client side? Do I just need to change to wss instead of ws and connect.
  2. What do I need to do on Linux vps hosting?
    I would appreciate any advice and examples.
  1. Using wss as the prefix of your URL should be enough to tell the client to connect usng the secure transport layer. However, you should use a domain name instead of an IP address, because that’s usually how SSL checks the host origin.
    Moreover, depending on your needs, I’d suggest to use the openfl.net.Socket class instead, which already uses Websockets on HTML5 targets.

  2. Your server has to handle SSL correctly, which means it manages its own certificate, usually generated for the relevant domain name(s). You might also want to check that the port you want to connect to is open on the host.

1 Like