Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8700065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:06:07+00:00 2026-06-13T02:06:07+00:00

I am a new starter to Node.Js and Redis. I got the Redis cookbook

  • 0

I am a new starter to Node.Js and Redis. I got the Redis cookbook and was trying out the Chat client & Server recipe.

I was wondering if anybody got the code to work or if there is some bug in the code.

I dont see where the sent messages from the client get invoked on the server.

Any help would be great.

Regards,
Tom

Client Code:

<?php

?> 

<html>
<head>
<title></title>


<script src="http://192.168.0.118:8000/socket.io/socket.io.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>

<script>


var socket = io.connect('192.168.0.118',{port:8000});

socket.on('message', function(data){
alert(data);
//var li = new Element('li').insert(data);
//$('messages').insert({top: li});
});


</script>

</head>

<body>

<ul id="messages">
<!-- chat messages go here -->
</ul>

<form id="chatform" action="">
<input id="chattext" type="text" value="" />
<input type="submit" value="Send" />
</form>
<script>

$('#chatform').submit(function() {
socket.emit('message', 'test'); //$('chattext').val());
$('chattext').val(""); // cleanup the field
return false;
});

</script>


</body>
</html>

Server Code:

var http = require('http');
io = require('socket.io');

redis = require('redis');
rc = redis.createClient();
//rc1 = redis.createClient();

rc.on("connect",function(){
rc.subscribe("chat");
console.log("In Chat Stream");
});

rc.on("message",function (channel,message){

 console.log("Sending hope: " + message);
 //rc1.publish("chat","hope");
 socketio.sockets.emit('message',message);
});

server = http.createServer(function(req,res){

res.writeHead(200,{'content-type':'text/html'});
res.end('<h1>hello world</h1>');

});

server.listen(8000);

var socketio = io.listen(server);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:06:08+00:00Added an answer on June 13, 2026 at 2:06 am

    It looks like you’re not listening for any connect / message events from socket.io.. try something like

    socketio.sockets.on('connection', function(socket) {
       console.log("Got connection");
       socket.on('message', function(msg) {
           rc1.publish("chat", msg);
       });
    });
    

    You’ll need to uncomment your rc1 up there, you will need that second redis connection

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm fairly new to node.js and am trying to ping my mysql database to
Fairly new to Node.js Made an app that runs a server process and serve
I am trying to figure out how to use a node graph for processing
I am new to programming and I am trying to learn node.js and CoffeeScript.
I have starter new System.Diagnostics.Process and it launchs FireFox. How can I obtain the
Is there any essential difference between this code: ThreadStart starter = new ThreadStart(SomeMethod); starter.Invoke();
I just created a new project using the visual studio cordova starter template. However
I set up a brand new project using the PhoneGap starter template in Visual
I started a new job recently. I've been a Java & XML web developer
Here is a real version control system dummy! proper new starter! The way I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.