Answer the question
In order to leave comments, you need to log in
How to setup widget on Yii2 yii2-node-socket?
It's a little unclear how to set up the yii2-node-socket widget. I'm getting errors in the console
GET crm/frontend/web/assets/c82ee7b9/client/client.js view?id=38:830
GET localhost:3001/socket.io/socket.io.js net::ERR_CONNECTION_REFUSED view?id=38:829
GET crm /frontend/web/assets/c82ee7b9/client/client.js view?id=38:830
###Events
###Work in javascript
Use YiiNodeSocket class
####Start work
// create object
var socket = new YiiNodeSocket();// enable debug mode socket.debug(true); socket.onConnect(function () { // fire when connection established }); socket.onDisconnect(function () { // fire when connection close or lost }); socket.onConnecting(function () { // fire when the socket is attempting to connect with the server }); socket.onReconnect(function () { // fire when successfully reconnected to the server });
'nodeSocket' => [
'class' => '\YiiNodeSocket\NodeSocket',
'dbOptions' => '',
'host' => 'localhost',
'allowedServerAddresses' => [
"localhost",
"127.0.0.1"
],
'origin' => '*:*',
'sessionVarName' => 'PHPSESSID',
'port' => 3001,
'socketLogFile' => '/var/log/node-socket.log',
],
Use (./yii node-socket/)
$> ./yii node-socket/start # start server
$> ./yii node-socket/stop # stop server
$> ./yii node-socket/restart # restart server
$ > ./yii node-socket/get-pid # show pid of nodejs process
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question