JedisSocketFactory.createSocket must return a connected socket ready to carry Redis traffic. In Jedis 5.2.0, the application supplies that factory and its Redis client configuration here:

var jedis = new Jedis(socksSocketFactory, redisConfig);

socksSocketFactory implements redis.clients.jedis.JedisSocketFactory, and redisConfig is the application's JedisClientConfig. Be ready to connect when the constructor runs: it can perform authentication and other Redis setup immediately.

Follow one socket from creation to handoff

For an unauthenticated SOCKS5 route, the factory can create a java.net.Socket with an explicit Proxy.Type.SOCKS intermediary, then connect to the Redis host and port. Keep the destination unresolved if the SOCKS server should resolve its hostname.

Bound the connect attempt and apply the intended read timeout. If connection fails, close that socket and report JedisConnectionException; the factory interface does not declare checked IOException.

If Redis requires TLS, establish and verify TLS before handing the socket back. A separate flag cannot be assumed to transform an arbitrary factory-returned socket. For a pool, repeat this lifecycle with a fresh socket on every factory call, including replacement connections.

An HTTP selection in a global ProxySelector is not an alternative implementation of this work. Redis sends RESP over its socket; it does not thereby become HTTP or negotiate CONNECT.

Mikanda mikatakata