I did a very simple test on Azure redis server but it always get I/o timeout. code is as below. I thought it is some Azure problem but if I create a python client using redis lib it works. so what could be problem
package rediscache_test
import (
"fmt"
"testing"
"github.com/go-redis/redis"
)
var client *redis.Client
func CreateNewClient() {
client = redis.NewClient(&redis.Options{
Addr: "xxxx.redis.cache.windows.net:6380",
Password:"xxxxx",
DB: 0, // use default
})
fmt.Println(client.ClientGetName())
}
func TestCommand(t *testing.T) {
CreateNewClient()
val := client.Get("foo")
fmt.Println(val)
}
BTW, attached is working python program
import redis
r = redis.StrictRedis(host='xxxx.redis.cache.windows.net',
port=6380, db=0, password='xxxx', ssl=True)
r.set('foo', 'bar')
print(r.get('foo'))
Golang error msg is like
get foo: read tcp IP:port->IP':6380: i/o timeout
I found out maybe it is due to that this client dose not support SSL?
Is there any simple way I can set up SSL=true, like in redigo
redis.DialURL(tt.url, dialTestConn(tt.r, &buf), redis.DialUseTLS(true))
Like this:
client = redis.NewClient(&redis.Options{
Addr: "xxxx.redis.cache.windows.net:6380",
Password:"xxxxx",
DB: 0, // use default
TLSConfig: &tls.Config{}, // your config here
})
Thanks, If I just want to enable SSL like SSL=true, how do I put this config?
/commands.go
Simplest TLS config is &tls.Config{InsecureSkipVerify: true}.
Most helpful comment
Simplest TLS config is
&tls.Config{InsecureSkipVerify: true}.