I have a websocket configurations done using ratchet, I am seeing it taking 50% of my CPU and because of other process it is reaching 100%. Any leads on how to troubleshoot? Machine Specs: 8 Core CPU, 4Gigs of RAM
You should use ws instead of socket.io if you want a lighter option. This example is exactly what I use for my ws configuration. Here it only listens for 'message' and sends it back to each socket stored in an array //--- begin server side ---// const Server = require('ws').Server const portTCP = 8093 var wss = new Server({port: portTCP}) var sockets = [] wss.on('connection', function (ws) { console.log('connected') ws.on('message', function (msg) { var message = JSON.parse(msg) for(i = 0; i < sockets.length; i++) { sockets[i].send(JSON.stringify(message)) } }) sockets.push(ws) ws.on('close', function () { // on socket close }) }) //--- begin client side ---// const socket = new WebSocket('ws://ip.address.here:8093') sendMessage() function sendMessage() { var messageType = 'text' socket.send(JSON.stringify({"messageType": messageType,"userName": userName,"message": messageBox.value, "socket": 0})) } socket.onmessage = function(msg) { var message = JSON.parse(msg.data) console.log('Message: ' + message.message) }
I'm a beginner with WebSocket and I'd like to use it for notification and commenting on my website... Since I'm using PHP for my backend, does Ratchet fits my needs?
Why does everyone show the same fucking shit ass chat example, literally the easiest thing to ever make, been looking for a way to implement server push communication with no progress
I love an excellent talk and this is definitely one! Thank you and well done ❤
Awesome presentation! I wish I would have found this earlier.
insightful and well-explained!
@Ted chau ruclips.net/video/746xBN3Fs9k/видео.html
if theres no client can we stop server auto and when some one connect then start running ??!?
man wish I had ratchet back five years ago. had to write ws server in C
You re great, perfect logic !
saludos, amigo, desde Medellin Colombia, gracias :D
well done nice presentation
Wish I was there. I have a lot of questions. Can I email you Jeff?
I have a websocket configurations done using ratchet, I am seeing it taking 50% of my CPU and because of other process it is reaching 100%. Any leads on how to troubleshoot? Machine Specs: 8 Core CPU, 4Gigs of RAM
So awkward, but i loved this
yes, difficult to listen to but thankfully he was presenting very useful information.
About 12:30 he said that theres socket support built into node. Which module is he referring to!
nodejs.org/api/net.html#net_class_net_socket
socket.io
You should use ws instead of socket.io if you want a lighter option. This example is exactly what I use for my ws configuration. Here it only listens for 'message' and sends it back to each socket stored in an array
//--- begin server side ---//
const Server = require('ws').Server
const portTCP = 8093
var wss = new Server({port: portTCP})
var sockets = []
wss.on('connection', function (ws) {
console.log('connected')
ws.on('message', function (msg) {
var message = JSON.parse(msg)
for(i = 0; i < sockets.length; i++) {
sockets[i].send(JSON.stringify(message))
}
})
sockets.push(ws)
ws.on('close', function () {
// on socket close
})
})
//--- begin client side ---//
const socket = new WebSocket('ws://ip.address.here:8093')
sendMessage()
function sendMessage() {
var messageType = 'text'
socket.send(JSON.stringify({"messageType": messageType,"userName": userName,"message": messageBox.value, "socket": 0}))
}
socket.onmessage = function(msg) {
var message = JSON.parse(msg.data)
console.log('Message: ' + message.message)
}
@@millersj socket.io is a node product. This is php
great, thank you
nice, thanks!
this guy is like "some websites still use this" about standard http requests like 95% of websites actually have any need for ajax. good talk anyway!
Why not increase number of file descriptors for PHP?
how can you do that?
Nobody asked how to start the 'server.php' file without terminal.! Well I dont know!
I see, php with websockets is painfull
webSocket with php is full of issues !
Well... I mean... PHP is not meant to do so...
I'm a beginner with WebSocket and I'd like to use it for notification and commenting on my website... Since I'm using PHP for my backend, does Ratchet fits my needs?
Why does everyone show the same fucking shit ass chat example, literally the easiest thing to ever make, been looking for a way to implement server push communication with no progress