yii-node-socket
yii-node-socket copied to clipboard
https support
need add https support!
Really appreciate the hardwork you have put in to get us this wonderful extension. I'm looking to add this plugin to my website which has https.
Have done modifications in two file. But I'm getting curl timeout when i try to send event.
Below are my changes.
/protected/extensions/yii-node-socket/lib/js/server/server.js
// Replacing http node server with https
// Http Config
//var express = require('express');
//var app = express();
//var server = require('http').createServer(app);
// Https Config
var fs = require('fs');
var options = {
key: fs.readFileSync('--path-to-key.pem--'),
cert: fs.readFileSync('--path-to-cert.pem--'),
passphrase: '--passphrase--'
};
var express = require('express');
var app = express();
var server = require('https').createServer(options, app);
/protected/extensions/yii-node-socket/lib/php/NodeSocket.php
// Replace http with https
// Yii::app()->clientScript->registerScriptFile(sprintf("http://%s:%d%s", $this->host, $this->port, '/socket.io/socket.io.js'));
Yii::app()->clientScript->registerScriptFile(sprintf("https://%s:%d%s", $this->host, $this->port, '/socket.io/socket.io.js'));
Can you please help me with this.
Hi i am try to implement it today, seems like in client js we need enable ssl connect, and need add some parameter to curl connection
Thank you for the quick reply. Yes, I have changed the file
/protected/extensions/yii-node-socket/lib/js/client/client.template.js
// Replace http with https
// socket = io.connect('http://<?php echo $nodeSocket->host;?>:<?php echo $nodeSocket->port;?>/client');
socket = io.connect('https://<?php echo $nodeSocket->host;?>:<?php echo $nodeSocket->port;?>/client');
Still, I was getting curl timeout when i try to send event. Please let me know, if I need to do any changes in other files.
Hi, try find place of creating elephant io client, and try change parameter, into cosyructor, checkSslpeer, try find and check this
Now i can not fix it, because do not have internet connection
Really appreciate your support and hints to get this extension up and running in https connection.
To summarize, these are the changes i have done to get it work.
/protected/extensions/yii-node-socket/lib/js/server/server.js
// Replacing http node server with https
// Http Config
//var express = require('express');
//var app = express();
//var server = require('http').createServer(app);
// Https Config
var fs = require('fs');
var options = {
key: fs.readFileSync('--path-to-key.pem--'),
cert: fs.readFileSync('--path-to-cert.pem--'),
passphrase: '--passphrase--'
};
var express = require('express');
var app = express();
var server = require('https').createServer(options, app);
/protected/extensions/yii-node-socket/lib/php/NodeSocket.php
// Replace http with https
// Yii::app()->clientScript->registerScriptFile(sprintf("http://%s:%d%s", $this->host, $this->port, '/socket.io/socket.io.js'));
Yii::app()->clientScript->registerScriptFile(sprintf("https://%s:%d%s", $this->host, $this->port, '/socket.io/socket.io.js'));
/protected/extensions/yii-node-socket/lib/js/client/client.template.js
// Replace http with https
// socket = io.connect('http://<?php echo $nodeSocket->host;?>:<?php echo $nodeSocket->port;?>/client');
socket = io.connect('https://<?php echo $nodeSocket->host;?>:<?php echo $nodeSocket->port;?>/client');
/protected/extensions/yii-node-socket/lib/php/frames/AFrame.php
protected function createClient() {
// Replace http with https
// return new \ElephantIO\Client(sprintf('http://%s:%s', $this->_nodeSocket->host, $this->_nodeSocket->port), 'socket.io', 1, false);
return new \ElephantIO\Client(sprintf('https://%s:%s', $this->_nodeSocket->host, $this->_nodeSocket->port), 'socket.io', 1, false);
}
php.ini
; Add below line
curl.cainfo= /path-to-CA_bundle.pem