Before applying ssl(I take from cloudflare) my website is loaded over http and my socket connection is made over ws
and it's working fine and connection was made successfully.
conn = new WebSocket('ws://myDomain:8090');
But after applying ssl when my website loads over https the I use wss (otherwise it give error)
conn = new WebSocket('wss://myDomain:8090');
Now it gives me the error
WebSocket connection to 'wss://myDomain:8090/' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT
The websocket server is started over 8090 port I also change the port to 9991 but to no avail.
Here is the code for websocket server
public function handle()
{
$server = IoServer::factory(
new HttpServer(
new WsServer(
new WebSocketController()
)
),
8090
);
$server->run();
}
I don't configure apache to to run a websocket server to accept secure connection request. May be due to this I am getting an error. It means that I am sending a secure connection request to an insecure websocket server. If I am right can you tell me how I configure my websocket server so that it can accept secure connection request.
I am again telling you that I am using the SSL from cloud flare. I tell me my domain and they provide me nameservers to replace it with my existing nameservers.
I requested you to give a clear solution to solve this. I am not using nginx, I am using apache on Lampp.
Copyright Notice:Content Author:「habib」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/55097326/how-to-configure-websocket-server-to-accept-secure-connection-request