Create Websocket

Discussion in 'Installation/Configuration' started by senormedia, Apr 23, 2022.

  1. senormedia

    senormedia Member HowtoForge Supporter

    I have ratchet on a site and cannot connect
    I opened a port on the firewall settings but it does not work or get a console log
    i followed this instructions http://socketo.me/docs/hello-world
    Am i missing something

    I have both nginx and apache server
     
  2. ahrasis

    ahrasis Well-Known Member

    What do you mean by having both nginx and apache server?
     
  3. senormedia

    senormedia Member HowtoForge Supporter

    Solution for Apache

    Make sure you have
    mod_proxy.so
    mod_proxy_wstunnel.so

    Open port you want on firewall
    Create Regular website on ispconfig
    Go to Apache Directives and add a proxy
    ProxyPass /wss2/ ws://enchufe.domain.com:2424/
    ProxyPassReverse /wss2/ ws://enchufe.domain.com:2424/

    replace domain and port with whatever you created and opened

    Go to command prompt and run php server.php where ratchet is located

    then you can test with js
    var conn = new WebSocket("wss://enchufe.domain.com/wss2");
    conn.onopen = function (e) {
    console.log("Connection established!");
    };
     
    ahrasis likes this.

Share This Page