using ngrok with websocket (or socket.io)
Yes. If your node app is working off of port 3000 like in your example then just use ngrok to create a reverse proxy to expose 3000 to the world. Websockets will work just fine with it.
Yes. If your node app is working off of port 3000 like in your example then just use ngrok to create a reverse proxy to expose 3000 to the world. Websockets will work just fine with it.
Alternatively, you can hijack the ‘router:request’ event to plug in passport for socket requests. I do this in ‘config/bootstrap.js’: module.exports.bootstrap = function (cb) { var passport = require(‘passport’), initialize = passport.initialize(), session = passport.session(), http = require(‘http’), methods = [‘login’, ‘logIn’, ‘logout’, ‘logOut’, ‘isAuthenticated’, ‘isUnauthenticated’]; sails.removeAllListeners(‘router:request’); sails.on(‘router:request’, function(req, res) { initialize(req, res, function () { … Read more
This is an old question, but for other people like me, who are looking how to configure reconnect in socket.io (1.x) here is a correct syntax: var socket = new io.connect(‘http://localhost:8181’, { ‘reconnection’: true, ‘reconnectionDelay’: 1000, ‘reconnectionDelayMax’ : 5000, ‘reconnectionAttempts’: 5 });
Set proxy from commandline. npm config set proxy http://proxydomain:port/ If error occur yet, additional try next. npm config set registry http://registry.npmjs.org/ These work for me. (ref http://sushichop.blogspot.jp/2013/01/npm-install.html)
WebSocket is, at its heart, just a set of framing for TEXT or BINARY data. It performs no compression on its own. However, the WebSocket spec allows for Extensions, and there have been a variety of compression extensions in the wild (the formalized specs for one of these is finalized). As of today (August 2018) … Read more
When your server listens, you usually get a socket at the “connection” event : require(‘socket.io’).on(‘connect’, function(socket){ A socket connects 2 points : the client and the server. When you emit on this socket, you emit to this specific client. Example : var io = require(‘socket.io’); io.on(‘connect’, function(socket){ socket.on(‘A’, function(something){ // we just received a message … Read more
Yes, there is. 1) query is like GET parameters, so replace “param:value” with “param=value” (if you want to pass multiple parameters, do it as you usually do with URL: param=value&some_other_param=test) 2) There is an easier and more reliable (because there is no risk to access an undefined property of handshaken object) way to get query … Read more
If you can install a key-value store like Redis on your node server, you can access it remotely from your php server using a Redis client like Predis. All you have to do is updating the remote session store on node server when a new login/logout happens in your php server. Check this post for … Read more