1

Recently, I started working with RedisJson with node, but I also have to work with Java version of it.

I'm trying to create a connection as it is mentioned in this github repo: https://github.com/RedisJSON/JRedisJSON

The repo shows connection with "localhost", but I want to connect to my remote Redis server instance which has the URL like redis://:password@host:port.

I'm trying to pass the host and port like the following: JReJSON jsonClient = new JReJSON("redis://:password@host", port);

But I'm getting the following error saying 'Failed to create socket' and 'UnknownHostException': enter image description here

enter image description here

But, I'm able to connect to the same host from command line. Could someone point out what is the issue or what is the actual way to connect to remote instance with RedisJSON in java?

Note: I'm using Jedis - jedis-4.3.1.jar and Rejson - jrejson-1.4.0.jar

Gowthamss
  • 191
  • 1
  • 2
  • 13

1 Answers1

2

Part 1: About the library

Check what the JRedisJSON home page says:

As of Jedis 4.0.0 this library is deprecated.

Since Jedis 4.0.0, you won't need jrejson/JRedisJSON separately. As you're already using jedis-4.3.1, you're good to go only with Jedis.

Check their quick start.

Part 2: About the constructor

You want to create client object from host, post and password. Check following two constructors:

  1. new JedisPooled("redis://:password@host:port")
  2. new JedisPooled(host, port, user, password) -> new JedisPooled(host, port, null, password)
sazzad
  • 5,740
  • 6
  • 25
  • 42
  • Hi @sazzad, thanks for the answer. I am now able to use json commands with Jedis. But one thing is the I can't use Jedis pipelining with json commands. Is there any way around using pipelining with json commands? – Gowthamss Nov 28 '22 at 03:37
  • @Gowthamss Please post new question explaining how you can't use Jedis pipelining with json commands. – sazzad Nov 28 '22 at 03:47
  • there was a mistake in how I was creating the pipeline. It is working actually. – Gowthamss Nov 28 '22 at 05:40