加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 连接到窗口10 ruby?? on rails上的redis服务器

发布时间:2020-12-17 02:09:54 所属栏目:百科 来源:网络整理
导读:我在 Windows 10上的rails应用程序中连接到redis时遇到问题,我将redis添加到我的gem文件并设置了我的cable.yml文件.当我启动我的rails服务器时我得到的错误是在establish_connection中进行救援’:超时连接到localhost上的Redis:6379如何解决此问题. cable.
我在 Windows 10上的rails应用程序中连接到redis时遇到问题,我将redis添加到我的gem文件并设置了我的cable.yml文件.当我启动我的rails服务器时我得到的错误是在establish_connection中进行救援’:超时连接到localhost上的Redis:6379如何解决此问题.

cable.yml

development:
  adapter: redis
  url: redis://localhost:6379/1

test:
  adapter: async

production:
  adapter: redis
  url: redis://localhost:6379/1

命令行

C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:318:in `rescue in establish_connection': Timed out connecting to Redis on localhost:6379 (Redis::CannotConnectError)
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:311:in `establish_connection'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:91:in `block in connect'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:273:in `with_reconnect'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:90:in `connect'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:256:in `with_socket_timeout'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:267:in `without_socket_timeout'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:122:in `call_loop'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/subscribe.rb:35:in `subscription'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/subscribe.rb:12:in `subscribe'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:2587:in `_subscription'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:2008:in `block in subscribe'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:37:in `block in synchronize'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:37:in `synchronize'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:2007:in `subscribe'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/actioncable-5.0.3/lib/action_cable/subscription_adapter/redis.rb:75:in `block in listen'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:273:in `with_reconnect'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:43:in `block in with_reconnect'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:37:in `block in synchronize'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:37:in `synchronize'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:42:in `with_reconnect'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:49:in `without_reconnect'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/actioncable-5.0.3/lib/action_cable/subscription_adapter/redis.rb:72:in `listen'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/actioncable-5.0.3/lib/action_cable/subscription_adapter/redis.rb:146:in `block in ensure_listener_running'

C:UsersMichaelDesktoprubychat>

解决方法

好吧,我遇到了同样的问题,这对我来说是有用的.linelymlconfig:

development:
  adapter: async

疯狂的是,它实际上连接到我的本地redis服务器!我想它不应该在配置中使用redis,但它正在使用它并且它工作得很好.

相反,如果我设置我认为正确的配置,它会失败:

development:
  :adapter: redis
  :url: redis://localhost:6379/

这是错误:

C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:345:in `rescue in establish_connection’: Error connecting to Redis on localhost:6379 (Redis::TimeoutError) (Redis::CannotConnectError)

所以,我不知道为什么,如果有人可以解释它会很棒,但是使用适配器:async它为我解决了(Rails 5.0.7,Windows 10,redis gem 3.3.3).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读