Nov 29, 2023
0
Level 1
How to fix ERR_SSL_PROTOCOL_ERROR Socket.IO Laravel
When I run it on localhost, everything works fine. However, when using a VPS (Ubuntu - Nginx), I encounter the error 'GET https://example.com:6001/socket.io/socket.io.js net::ERR_SSL_PROTOCOL_ERROR.' Even though I have added the port and SSL, it still functions normally at https://example.com. Here is the code:
<script src="//{{ Request::getHost() }}:{{ env('LARAVEL_ECHO_PORT') }}/socket.io/socket.io.js"></script>
<script src="{{ url('/js/laravel-echo-setup.js') }}"></script>
And in laravel-echo-setup.js:
import Echo from "laravel-echo";
window.laravel_echo_port = 6001;
window.Echo = new Echo({
broadcaster: "socket.io",
host: window.location.protocol + "//" + window.location.hostname + ":" + window.laravel_echo_port,
});
Please or to participate in this conversation.