redis / go-redis

Redis Go client
https://redis.uptrace.dev
BSD 2-Clause "Simplified" License
19.91k stars 2.34k forks source link

unable to connect redis on azure #1334

Closed RaynDol closed 9 months ago

RaynDol commented 4 years ago

Im trying to connect to reds in azure I use the following code

import (
      "fmt"
       "os"
       "github.com/go-redis/redis"
        )
    func main() {
         uri := os.Getenv("uri")
         fmt.Println("uri is", uri)
         opt, err := redis.ParseURL(uri)
         if err != nil {
             fmt.Println(err)
          }
         fmt.Println("addr is:”, opt.Addr)
         fmt.Println("db is:”, opt.DB)
         fmt.Println("password is:”, opt.Password)
         //connect to redis
         client = redis.NewClient(opt)
         pong, err := client.Ping().Result()

The printed data is like

uri is rediss://:bBMfQ7wFdkPHr8u%2B2zzNOzUpy85OEjYv7KbPZd8B89M%3D@e49ab3c6-8f72-416a-a6c1-ddfe75gf200e.redis.cache.windows.net:6380

addr is: e49ab3c6-8f72-416a-a6c1-ddfe75gf200e.redis.cache.windows.net:6380
db is: 0
password is: bBMfQ7wFdkPHr8u+2zzNOzUpy85OEjYv7KbPZd8B89M=

The redis service is up and running and I was able to connect with node application and get the data, any idea why I got the error:

dial tcp 40.128.8.87:6380: connect: connection refused

im using version v6.15.7 I tried also with 6.15.8 with same results

Btw,

we are in procees to migrate some nodjs apps to golang and using the following code in node, works! do I miss something ?

const redisClient = redis.createClient(process.env.uri);

redisClient.on("connect", () => console.log("Redis is connected"));

I've provisioned a new instance without ssl which is not working either

This is the logs

uri is redis://:TKq1n%2BO29jsSdIkoysXL%2Btwd6Xi0IO0KNxw%3D@2dca2dx1-20e0-48ca-83ed-20bf52e99b97.redis.cache.windows.net:6379
addr is 2dca2dx1-20e0-48ca-83ed-20bf52e99b97.redis.cache.windows.net:6379
db is 0
password is TKq1n+O29jsSdIkoysXL+twd6Xi0IO0KNxw=

dial tcp 40.113.7.3:6379: connect: connection refused

github-actions[bot] commented 12 months ago

This issue is marked stale. It will be closed in 30 days if it is not updated.