Hi there @Aaron_Wilson,
Yes it is possible I have tried it myself !!
here is a picture of the server receiving messages
here is a picture of a client sending messages
here is the code used for the simple ws server
Sample codes for those who want to try
here is the code for the client
<script>
var conn = new WebSocket('wss://sok.onrender.com');
conn.onopen = function(e) {
console.log("Connection established!");
};
setInterval(() => {
conn.send('Hello server!');
}, 1000);
conn.onmessage = function(e) {
console.log(e.data);
};
conn.onclose = function(e) {
console.log(e.code);
console.log(e.reason);
};
conn.onerror = function(e) {
console.log(e);
};
</script>
I have also tried socket.io and it works like a charm just make sure your then your testing in your localhost you do it in https://localhost/app
code for client (socket.io)
<script>
try{
console.log("msg")
var socket = io("socket-lb02.onrender.com", {transports: ['websocket']});
socket.on('message', function(msg){
console.log(msg)
el = document.getElementById('server-time');
el.innerHTML = 'Message ' + msg;
});
setInterval(() => {
count++
socket.emit('messaged',"count")
console.log(count)
}, 1000);
}catch (error){
alert(error)
};
</script>
Code for server
Happy coding