Websocket with apache mod_proxy_wstunnel doesn't work
<p>I have made a good preparation: Apache 2.4 + PHP7 + WebSocket<br>
Visit this link to see my preparation<br>
details: <a href="https://stackoverflow.com/questions/39737463/cannot-load-modules-mod-proxy-wstunnel-so-into-server">Cannot load modules/mod_proxy_wstunnel.so into server</a><br>
But when I run a simple WebSocket demo, I am meet with some problems. I have no idea how to solve them.</p>

<p>Websocket is a new concept to me. I have learned that Apache 2.4 supports WebSockets with <code>mod_proxy_wstunnel.so</code>.<br>
My steps:</p>

<ol>
<li>Edit httpd.conf, load <code>mod_proxy</code> and <code>mod_proxy_wstunnel</code> (of course both are in apachedir/modules)</li>
</ol>

<pre class="lang-none prettyprint-override"><code>LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
</code></pre>

<ol start="2">
<li>Add proxy (still in httpd)</li>
</ol>

<pre class="lang-none prettyprint-override"><code>ProxyPass /ws ws://10.180.0.123/
ProxyPassReverse /ws ws://10.180.0.123/
</code></pre>

<ol start="3">
<li>create HTML client and PHP server (<code>cd apachedir/htdocs</code>)</li>
</ol>

<p>client.html</p>

<pre class="lang-html prettyprint-override"><code>&lt;html&gt;
&lt;script&gt;
    var socket = new WebSocket("ws://10.180.0.123/server.php");
    socket.onopen = function(e){
        console.log("open success");
    }
    socket.onmessage = function(e){
        console.log("mes:"+e);
    }
    //socket.close();
    socket.send("Hello World");
&lt;/script&gt;
&lt;html&gt;
</code></pre>

<p>server.php</p>

<pre class="lang-html prettyprint-override"><code>&lt;?php
  echo "hello";
?&gt;
</code></pre>

<p>4.start apache</p>

<pre><code>/usr/local/apache2/bin/apachectl start
</code></pre>

<p>My questions:</p>

<ol>
<li>When I open: <code>10.180.0.123/client.html</code>, I got the following error:</li>
</ol>

<pre class="lang-none prettyprint-override"><code>Uncaught InvalidStateError: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.  
WebSocket connection to 'ws://10.180.0.123/server.php' failed: Error during WebSocket handshake: Unexpected response code: 200  
</code></pre>

<p>I guess I should write some code in <code>server.php</code>, and run it. Am I right? And what should I write. I didn't find any information on google.</p>

<ol start="2">
<li>When I open: <code>10.180.0.123/ws/client.html</code>, I get the following Apache error logs</li>
</ol>

<pre class="lang-none prettyprint-override"><code>[Wed Sep 28 00:14:54.063989 2016] [proxy:warn] [pid 6646:tid 140326217934592] [client 10.230.0.93:57508] AH01144: No protocol handler was valid for the URL /ws/client.html. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
</code></pre>

<p>It seems the proxy module was not be loaded, but see my screenshot:</p>

<p><a href="https://i.stack.imgur.com/cVRoW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cVRoW.png" alt="loaded modules screenshot"></a></p>