远程服务器中的Redis配置

时间:2018-04-12 12:28:21

标签: redis

经过几次谷歌搜索后,我发布了这个问题直到5天。我有一个云服务器,我安装了redis服务器。我想通过我的c#代码连接redis服务器。我已经尝试了很多次但是我的代码失败了。

我对绑定配置感到困惑,我应该在绑定XX.XX.XX.XXXX中放入哪个IP地址。服务器IP地址或我的开发机器IP地址。

引发错误:  PING上的套接字失败

 private static Lazy<ConfigurationOptions> configOptions = new Lazy<ConfigurationOptions>(() =>
    {
        var configOptions = new ConfigurationOptions();
        configOptions.EndPoints.Add("192.XXX.XXX.XXX:6379");
        configOptions.ClientName = "ATLDCYZ082158";
        configOptions.ConnectTimeout = 100000;
        configOptions.AbortOnConnectFail = false;
        configOptions.Ssl = false;
        configOptions.SyncTimeout = 100000;
        return configOptions;
    });

私有静态ConnectionMultiplexer conn;

    private static ConnectionMultiplexer LeakyConn
    {
        get
        {
            if (conn == null || !conn.IsConnected)
                conn = GetConnectionMultiplexer();
            return conn;
        }
    }



private static ConnectionMultiplexer GetConnectionMultiplexer()
    {
        var sw = new StringWriter();
        try
        {              

           var connectionMultiplexer = ConnectionMultiplexer.Connect(configOptions.Value, sw);
           var log = sw.ToString();
           return connectionMultiplexer;
        }
        catch (Exception ex)
        {
            var log = sw.ToString();
            return null;
        }
    }

任何人都可以帮助我。

0 个答案:

没有答案
相关问题