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 6541817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:09:04+00:00 2026-05-25T11:09:04+00:00

Trying to create two clients; one is pub/sub, the other is a standard connection.

  • 0

Trying to create two clients; one is pub/sub, the other is a standard connection. Is this not possible? There must be a way to abstract this to work 🙂 Basically, if I do a get key after running test.js, all I see is ‘valueBefore’. The output:

node test.js 
Reply: OK

/Users/franklovecchio/Desktop/development/node/node_modules/redis/index.js:487
        throw new Error("Connection in pub/sub mode, only pub/sub commands may
              ^
Error: Connection in pub/sub mode, only pub/sub commands may be used
    at RedisClient.send_command (/Users/franklovecchio/Desktop/development/node/node_modules/redis/index.js:487:15)
    at RedisClient.<anonymous> (/Users/franklovecchio/Desktop/development/node/node_modules/redis/index.js:597:27)
    at Object._onTimeout (/Users/franklovecchio/Desktop/development/node/distributed-cache/client/test.js:19:12)
    at Timer.callback (timers.js:83:39)

The code:

var redis = require('redis');

var client1 = redis.createClient();
var client2 = redis.createClient();

client2.on('message', function (channel, message) {
    console.log('Received a message on channel: ' + channel);       

    client1.set('key', message, redis.print);

});

client2.subscribe('channel');

client1.set('key', 'valueBefore', redis.print);

setTimeout(
    function() {
        client2.publish('channel', 'valueAfter');
    },3000
);
  • 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-05-25T11:09:05+00:00Added an answer on May 25, 2026 at 11:09 am

    You probably need to publish messages from client1 since client2 is dedicated to listening for messages on certain channel. Few words about this behavior are written in node_redis readme:

    If you need to send regular commands to Redis while in pub/sub mode,
    just open another connection.

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

Sidebar

Related Questions

I'm trying to create a standard two-column form, where the first column is a
I'm trying to use the DSACryptoServiceProvider class with C# to create two DLLs: one
I'm trying to create a good way to handle all possible collisions between two
I'm trying to make two clients (players) contact each other (exchanging for example strings)
I'm trying to create two ASP.NET Membership login pages for an ASP.NET website I'm
I am trying to create two different sets of settings for datepicker( http://keith-wood.name/datepick.html )
I'm trying to create a two-level horizontal navigation menu (or menubar) that displays the
I'm trying to create a table with two columns comprising the primary key in
I am trying to create a unique constraint on two fields in a table.
I am trying to create a rewrite rule that accomplishes two things: Redirect (www.)?domain.com

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.