Reputation: 384
I'm trying to set up websocket on my local machine to test it but I simply can't get it to work, nor find any guide that actually solves it.
So to sum up, can anyone tell me what's wrong with my settings?
I'm running Ububtu 16.04 and Apache 2.4.18 I have mod_proxy and mod_proxy_wstunnel enabeled
my Apache config looks like this
<VirtualHost *:80>
ServerName socket.localhost
ProxyRequests Off
ProxyPass "/ws2/" "ws://localhost:8546/"
ProxyPass "/wss2/" "wss://localhost:8546/"
</VirtualHost>
On the client side I have this javaScript
<script type="text/javascript">
var socket = new WebSocket('ws://socket.localhost');
socket.send('Test');
</script>
And I'm running
netcat -p 8546 -l
To see any connection
And lastly I have this line in my hosts file
127.0.0.1 socket.localhost
Whenever I run the JavaScript I get the error
Firefox can’t establish a connection to the server at ws://socket.localhost/.
Upvotes: 1
Views: 6791
Reputation: 10426
You javascript code should utilize the address ws://socket.localhost/ws2
, since this is what you have configured in the Apache proxy configuration.
Do you actually have a websocket server running at ws://localhost:8546
? You don't mention that in your description.
Upvotes: 2