Skip to content

Using AWS cluster - Trouble writing values to it #166

Open

Description

@ferchor2003

Hi,
Working on my app, everything looks fine in my local development environment with a single redis server on standard port. Running into problems when using an AWS environment with a cluster. Is there anything specific that needs to be set for a cluster?

The initial connection seems to go correctly using the following:

boost::redis::config cfg;
cfg.addr.host = "clustercfg.xxx-xxx-xxx.cache.amazonaws.com";
cfg.addr.port = "7000";
cfg.use_ssl = true;
cfg.clientname = "webserver";
cfg.log_prefix = "webserver.redis ";

and I see the following on std::cout, so it seems the cluster was correctly identified:

webserver.redis Resolve results: 10.32.35.71:7000, 10.32.35.244:7000, 10.32.34.195:7000, 10.32.34.189:7000
webserver.redis Connected to endpoint: 10.32.35.71:7000
webserver.redis SSL handshake: Success
webserver.redis Bytes written: 105
webserver.redis Hello: Success
webserver.redis Bytes written: 32

However, when trying an HSET operation I got an exception:
Exception saving session to Redis. %s - keyid - Got RESP3 simple-error. [boost.redis:11]

This is the code that tries to write to the Cluster: (redisInst is an instance of sync_connection as it came from the examples dir)

   request req;
   boost::redis::response<
   	int, // HSET
   	boost::redis::ignore_t// EXPIRE
   > res;	
   try {
   	req.push("HSET", key, "response", responseField);
   	req.push("EXPIRE", key, maxSessionTimeToLiveSecs, "NX");	// Have the session teid expire 
   	redisInst->exec(req, res);
   	return true;
   }
   catch ( const std::exception& e )
   {
   	LogError("Exception saving session to Redis. %s - %s", key.c_str(), e.what());
   }

Activity

  1. mzimbres commented on Nov 3, 2023

    @mzimbres
    Collaborator

    Running into problems when using an AWS environment with a cluster

    Do you mean a Redis cluster? So far there is not support for Redis-cluster in Boost.Redis.

  2. mzimbres commented on Nov 3, 2023

    @mzimbres
    Collaborator

    Got RESP3 simple-error. [boost.redis:11]

    It is important to know what message is contained in that error.

  3. mzimbres commented on Nov 3, 2023

    @mzimbres
    Collaborator

    Can you please replace response<int, boost::redis::ignore_t> with response<int, int> and add this to your code

          if (std::get<0>(resp).has_error()) {
             std::cout << "Type: " << to_string(std::get<0>(resp).error().data_type) << std::endl;    
             std::cout << "Diagnostic: " << std::get<0>(resp).error().diagnostic << std::endl;        
          }
          if (std::get<1>(resp).has_error()) {
             std::cout << "Type: " << to_string(std::get<1>(resp).error().data_type) << std::endl;    
             std::cout << "Diagnostic: " << std::get<1>(resp).error().diagnostic << std::endl;        
          }

    Let me then know what diagnostic do you get.

  4. ferchor2003 commented on Nov 3, 2023

    @ferchor2003
    Author

    This is what the response now:

    Type: simple_error
    Diagnostic: MOVED 10848 xxx-xxx-xxx-xxx-xxx.cache.amazonaws.com:7000
    Type: simple_error
    Diagnostic: MOVED 10848 xxx-xxx-xxx-xxx-xxx.cache.amazonaws.com:7000
    

    Where xxx-xxx-xxx is one of the cluster nodes

  5. mzimbres commented on Nov 3, 2023

    @mzimbres
    Collaborator

    Ok, this means you are using a Redis cluster. As I said above, Boost.Redis does not provide any facility for cluster setups. In this case you would have to deal with the redirect yourself as describe under the in MOVED Redirection, which means creating a new connection to that node and maintaining a map of connections to prevent from opening more than one connection to the same node. Feel free to open an issue to add Redis cluster support, however I can't give you an estimate about when I will come up with it.

  6. nqf commented on Apr 15, 2025

    @nqf

    Has there been any progress in supporting clusters?

  7. criatura2 commented on Apr 15, 2025

    @criatura2

    @nql Unfortunately no. That would be a large task and I don't have the resources for implementing it at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions