I'm running ubuntu and I am trying to deploy a socket.io / redis application. I have ran through both of these tutorials so I could get it to work. Which I did (kinda)Node Installation Redis InstallationI'm using port 3000 for my node server and when I runcurl http://localhost:3000 I get a successful message saying "hello world"but when I try to run it within my application it doesn't seem to be working. ( no error messages )#!/usr/bin/env nodejs var server = require('http').createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(3000, 'localhost'); var io = require('socket.io')(server); var Redis = require('ioredis'); var redis = new Redis(); redis.psubscribe('*', function(err, count) {}); redis.on('pmessage', function(subscribed, channel, message) { console.log(channel + ':' + message.event, message.data); message = JSON.parse(message); io.emit(channel + ':' + message.event, message.data); }); console.log("server started sucessfully"); Which I find kind of odd, because when I run the exact same script on my computer's localhost and not the server, it works.Can anyone point out what I might be doing wrong? This is my first time deploying a node server so please go easy one me.
Submitted January 04, 2017 at 01:21AM by soaringradio
No comments:
Post a Comment