Tried to couple it with a simple index.html client to test a connection to the server, but as soon as I load the client in the browser and the connection is estabilished, the connection is instantly closed:
The simple client's index.html that runs on an Apache vhost in the same machine at http://amphpws.local:8080/index.html, not publicly accessible:
<html>
<head>
<style>
input, button { padding:10px; }
</style>
</head>
<body>
<input type="text" id="message"/>
<button onclick="transmitMessage()">Send</button>
<script>
// Create a new WebSocket.
var socket = new WebSocket('ws://127.0.0.1:1337');
// Define the message
var message = document.getElementById('message');
function transmitMessage() {
socket.send(message.value);
}
socket.onmessage = function (e) {
alert(e.data);
}
</script>
</body>
</html>
The result in the Chrome browser:
The connection is closed as soon as I load the page so I can't even test in order to "Send" some message.
And as soon as I opened the issue, I realized that maybe I had to use ws://127.0.0.1:1337/broadcast in the client's websocket url, not plain ws://127.0.0.1:1337?
(Thank you for fixing the example)
Tried to couple it with a simple index.html client to test a connection to the server, but as soon as I load the client in the browser and the connection is estabilished, the connection is instantly closed:
The simple client's index.html that runs on an Apache vhost in the same machine at http://amphpws.local:8080/index.html, not publicly accessible:
The result in the Chrome browser:
The connection is closed as soon as I load the page so I can't even test in order to "Send" some message.