Hi all,
I need expert answer to this issue!
Consider the following node.js code to start an https server:
var enable_ssl = true; var app = express() , httpapp = express() , fs = require('fs') , options = { key: fs.readFileSync('./cert/client.key'), cert: fs.readFileSync('./cert/client.crt'), requestCert: true } , server = (enable_ssl ? require('https').createServer(options, app) : require('http').createServer(app)) , io = require('socket.io').listen(server);And consider the following Titanium codes to connect to a secured url:
var socket = io.connect("https://localhost:4343", {secure: true}); socket.on("connect", function() { if (logger.is_debug_enabled) logger.logDebug("socket.on(\"connect\", function() {"); }); socket.on("disconnect", function() { if (logger.is_debug_enabled) logger.logDebug("socket.on(\"disconnect\", function() {"); }); socket.on("error", function(a, b, c) { if (logger.is_debug_enabled) logger.logDebug("socket.on(\"error\", function() { a: " + JSON.stringify(a) + " b: " + JSON.stringify(b) + " c: " + JSON.stringify(c)); });I'm using socket.io (server) and socket.io-titanium (client) 0.9.
I've been testing with different scenarios arrived at the following conclusion:
- If I switch off the ssl (
enable_ssl = false
) everything works fine! Yay! However, we want it to be secured! - If I switch on the ssl, and use 'https://..' on the client-side, I got an error that 'wss://' is an invalid protocol! I got by this by changing ti-websocket-client.js codes from
if(!parsed || parsed[1] !== 'ws') {...
toif(!parsed || (parsed[1] !== 'ws' && parsed[1] !== 'wss')) {...
. However, it didn't fully work. The one thread in the app seems to get stuck atvar bytesRead = this._socket.read(buffer);
and eventually timed out.
I've read so many articles node.js, express, https, titanium in different permutations but none has so far tried this scenario I have.
So, I really need some expert/guru/superman advice here! Thanks in advance!