I've just create a PHP web server on local server, (Xampp environment, Windows) with Let's Encrypt SSL certificate (NOT SELF-SIGNED) so my website https://example.it looks like valid certificate with every browser. I can navigate to it both with http:// and https:// with standard ports.
Now I'm implementing php socket for creating web chat, however if I use insecure web socket protocol over HTTP:
ws://example.it:8090/chat/php-socket.php
it works.
If I use secure web socket protocol over HTTPS:
wss://example.it:8090/chat/php-socket.php
I receive an error on establishing connection net::ERR_SSL_PROTOCOL_ERROR
This is my code if someone needs:
$(document).ready(function(){
var websocket = new WebSocket("wss://example.it:8090/chat/php-socket.php");
websocket.onopen = function(event) {
showMessage("<div class='chat-connection-ack'>Connssione stabilita.</div>");
}
websocket.onmessage = function(event) {
var Data = JSON.parse(event.data);
console.log(Data);
showMessage("<div class='"+Data.message_type+"'>"+Data.message+"</div>");
$('#chat-message').val('');
};
});