Live Helper Chat support forum.. Forum is locked. New place for questions - Github Discussions

You are not logged in.

Announcement

#1 2014-07-13 22:18:37

Jessie Brickner
Member
Registered: 2014-07-13
Posts: 9

node.js / socket.io

It seems that the current version of nodejshelper doesn't play well with newer version of socket.io and node.js.  After several hours today, I finally managed to get it to connect over SSL. The problem I'm having is that, Operator to visitor chat updates on the visitor side when the message is sent, visitor to operator message will not appear for the operator until the operator sends a new message.
I'm not receiving any errors in the console log nor in the javascript console.
I would certainly appreciate it if someone would be able to provide any insight as where to look to resolve this issue!
Thanks!

https://groups.google.com/forum/#!topic … M3mYFxbH1M

Offline

#2 2014-07-14 01:08:52

Jessie Brickner
Member
Registered: 2014-07-13
Posts: 9

Re: node.js / socket.io

From what I can tell, syncadmin doesn't fire at all with nodejshelper extension enabled. On the other hand, syncuser does fire all the time for the user.

Offline

#3 2014-07-14 08:21:25

Remigijus Kiminas
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,661
Website

Re: node.js / socket.io

Hi,

Can you try re-download this extension. I have fixed compatibility with recent version of LHC. NodeJs version had nothing to do with it.

Here is related commit for reference.
https://github.com/LiveHelperChat/livehelperchat-extensions/commit/b86523f0f2455cd3300e3c8b47ed1a85b5df0e35


Thanks for report.

Offline

#4 2014-07-14 13:50:22

Jessie Brickner
Member
Registered: 2014-07-13
Posts: 9

Re: node.js / socket.io

I will give that a try!
And, I appreciate the hard work and time you've put into this product.  It is, in my opinion, better than any of the paid for applications that we looked at prior to finding this.

Offline

#5 2014-07-14 14:29:40

Jessie Brickner
Member
Registered: 2014-07-13
Posts: 9

Re: node.js / socket.io

Works like a charm! I'm going to provide you the changes I made to server.js in order to support the newer version of node.js and socket.io.  Some of the methods are not available in socket.io, such as enable(). Also, debugging changed, you can no longer set the log level.  They do provide a file at their CDN for socket.io that will enable the gzip compression and such but I wasn't able to figure out how to get it to work. It kept throwing errors but perhaps with your changes it would work.
Anyways, here is what I have in my server.js file:
var config = require('./settings');var fs = require('fs');
var options = {        key:fs.readFileSync("/path/to/cert/ssl.key"),        cert:fs.readFileSync("/path/to/cert/ssl.cert"),        ca:[fs.readFileSync("/path/to/cert/ssl.pem"),                fs.readFileSync("/path/to/cert/ssl.ca")]};
var http = require('https').createServer(options, function (req, res) {        res.writeHead(200);        res.end();});
var io = require(config.socketiopath).listen(http);
// enable all transports (optional if you want flashsocket support, please note that some hosting// providers do not allow you to create servers that listen on a port different than 80 or their// default port)
io.set('transports', ['websocket',                      'flashsocket',                      'htmlfile',                      'xhr-polling',                      'jsonp-polling',                      'polling']);

http.listen(config.web.port,config.web.host);
console.log('LHC Server listening on '+config.web.host+':'+config.web.port);
[Rest of file, after this point, remains unchanged]
You can find more information here: http://socket.io/blog/introducing-socket-io-1-0/http://stackoverflow.com/questions/23981741/minify-socket-io-socket-io-js-with-1-0

I hope this helps!
Thanks again,Jess

On Monday, July 14, 2014 1:21:25 AM UTC-5, Remigijus Kiminas wrote:Hi,

Can you try re-download this extension. I have fixed compatibility with recent version of LHC. NodeJs version had nothing to do with it.


Offline

#6 2015-08-31 15:54:24

nightkid
Member
Registered: 2015-08-31
Posts: 2

Re: node.js / socket.io

hi Remigijus,

Your work is tremendous, thank you!

Jessie's hack in this thread is the only way i found to make server.js listen on a HTTPS port, and it still works like a charm. Yet you mentioned elsewhere that everything now supports SSL out of the box. Am i missing something? Is there a natively supported way to listen HTTPS without hacking server.js ?

Offline

#7 2015-08-31 16:07:40

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,661
Website

Re: node.js / socket.io

Well, in my environment just nginx acts as proxy and SSL is terminated at nginx part.

Offline

#8 2015-08-31 17:21:23

nightkid
Member
Registered: 2015-08-31
Posts: 2

Re: node.js / socket.io

Thanks for the clarification. Just in case someone like me runs a frontend without proper websocket proxy support, here's Jessie's hack again with proper formatting:

var config = require('./settings');
var fs = require('fs');

var options = {
        key:fs.readFileSync("/path/to/cert/ssl.key"),
        cert:fs.readFileSync("/path/to/cert/ssl.cert"),
        ca:[fs.readFileSync("/path/to/cert/ssl.pem"),
                fs.readFileSync("/path/to/cert/ssl.ca")]
};

var http = require('https').createServer(options, function (req, res) {
        res.writeHead(200);
        res.end();
});

var io = require(config.socketiopath).listen(http);

// enable all transports (optional if you want flashsocket support, please note that some hosting
// providers do not allow you to create servers that listen on a port different than 80 or their
// default port)

io.set('transports', ['websocket',
                      'flashsocket',
                      'htmlfile',
                      'xhr-polling',
                      'jsonp-polling',
                      'polling'
]);


http.listen(config.web.port,config.web.host);

console.log('LHC Server listening on '+config.web.host+':'+config.web.port);

//Rest of file, after this point, remains unchanged

Offline

Board footer