我有一个railsapi,它将redis作为actioncable的适配器。
作为整个系统的一部分,我只使用actioncable进行简单的聊天。
一切都很完美,我可以订阅,发送信息,接收信息。问题出现在服务器启动5分钟后,我在redis gem中得到一个econnreset错误:connection lost(econnreset)(redis::connectionerror)
我已经三天没试着解决这个问题了,我试着改变redis服务器配置,我试着改变redis在rails应用程序上初始化的方式,我试着改变cable.yml配置,我试着改变actioncable配置,但似乎没有什么能解决这个问题,我已经没有主意了。
我也不能挽救这个例外,它只是打破了整个rails应用程序,这是另一件我无法解决的事情,这是如此令人沮丧。
顺便说一句,我正在开发环境中测试。
这是我的电缆配置:
production:
adapter: redis
url: redis://192.168.1.6:6379
development:
adapter: redis
url: redis://192.168.1.5:6379
channel_prefix: ChatChannel
timeout: 30
max_conns: 8000
max_persistent_conns: 8000
test:
adapter: async
这是我的redis初始化器:
require 'redis'
## Added rescue condition if Redis connection is failed
begin
puts "CREATING NEW INSTANCE OF REDIS"
$redis = Redis.new(
:host => "192.168.1.5",
:port => 6379,
:reconnect_attempts => 10,
:reconnect_delay => 1.5,
:reconnect_delay_max => 10.0
)
$redis.ping
rescue Errno::ECONNRESET => e
puts "THERE WAS AN ERROR"
puts e
end
这是rails应用程序的输出:
web_1 | Exiting
web_1 | #<Thread:0x0000559ee244b1d8 /usr/local/bundle/gems/actioncable-6.0.3.1/lib/action_cable/subscription_adapter/redis.rb:151 run> terminated with exception (report_on_exception is true):
web_1 | /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:275:in `rescue in io': Connection lost (ECONNRESET) (Redis::ConnectionError)
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:267:in `io'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:279:in `read'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:147:in `block (3 levels) in call_loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:146:in `loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:146:in `block (2 levels) in call_loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:248:in `block (2 levels) in process'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:389:in `ensure_connected'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:238:in `block in process'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:325:in `logging'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:237:in `process'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:145:in `block in call_loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:300:in `with_socket_timeout'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:144:in `call_loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/subscribe.rb:44:in `subscription'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/subscribe.rb:14:in `subscribe'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:3507:in `_subscription'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:2326:in `block in subscribe'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:69:in `block in synchronize'
web_1 | from /usr/local/lib/ruby/2.7.0/monitor.rb:202:in `synchronize'
web_1 | from /usr/local/lib/ruby/2.7.0/monitor.rb:202:in `mon_synchronize'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:69:in `synchronize'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:2325:in `subscribe'
web_1 | from /usr/local/bundle/gems/actioncable-6.0.3.1/lib/action_cable/subscription_adapter/redis.rb:84:in `block in listen'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:313:in `with_reconnect'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:75:in `block in with_reconnect'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:69:in `block in synchronize'
web_1 | from /usr/local/lib/ruby/2.7.0/monitor.rb:202:in `synchronize'
web_1 | from /usr/local/lib/ruby/2.7.0/monitor.rb:202:in `mon_synchronize'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:69:in `synchronize'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:74:in `with_reconnect'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:81:in `without_reconnect'
web_1 | from /usr/local/bundle/gems/actioncable-6.0.3.1/lib/action_cable/subscription_adapter/redis.rb:81:in `listen'
web_1 | from /usr/local/bundle/gems/actioncable-6.0.3.1/lib/action_cable/subscription_adapter/redis.rb:155:in `block in ensure_listener_running'
web_1 | /usr/local/bundle/gems/redis-4.2.5/lib/redis/connection/ruby.rb:63:in `block in _read_from_socket': Connection reset by peer (Errno::ECONNRESET)
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/connection/ruby.rb:52:in `loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/connection/ruby.rb:52:in `_read_from_socket'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/connection/ruby.rb:45:in `gets'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/connection/ruby.rb:378:in `read'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:280:in `block in read'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:268:in `io'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:279:in `read'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:147:in `block (3 levels) in call_loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:146:in `loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:146:in `block (2 levels) in call_loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:248:in `block (2 levels) in process'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:389:in `ensure_connected'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:238:in `block in process'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:325:in `logging'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:237:in `process'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:145:in `block in call_loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:300:in `with_socket_timeout'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:144:in `call_loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/subscribe.rb:44:in `subscription'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/subscribe.rb:14:in `subscribe'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:3507:in `_subscription'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:2326:in `block in subscribe'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:69:in `block in synchronize'
web_1 | from /usr/local/lib/ruby/2.7.0/monitor.rb:202:in `synchronize'
web_1 | from /usr/local/lib/ruby/2.7.0/monitor.rb:202:in `mon_synchronize'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:69:in `synchronize'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:2325:in `subscribe'
web_1 | from /usr/local/bundle/gems/actioncable-6.0.3.1/lib/action_cable/subscription_adapter/redis.rb:84:in `block in listen'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:313:in `with_reconnect'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:75:in `block in with_reconnect'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:69:in `block in synchronize'
web_1 | from /usr/local/lib/ruby/2.7.0/monitor.rb:202:in `synchronize'
web_1 | from /usr/local/lib/ruby/2.7.0/monitor.rb:202:in `mon_synchronize'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:69:in `synchronize'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:74:in `with_reconnect'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:81:in `without_reconnect'
web_1 | from /usr/local/bundle/gems/actioncable-6.0.3.1/lib/action_cable/subscription_adapter/redis.rb:81:in `listen'
web_1 | from /usr/local/bundle/gems/actioncable-6.0.3.1/lib/action_cable/subscription_adapter/redis.rb:155:in `block in ensure_listener_running'
web_1 | /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:275:in `rescue in io': Connection lost (ECONNRESET) (Redis::ConnectionError)
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:267:in `io'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:279:in `read'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:147:in `block (3 levels) in call_loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:146:in `loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:146:in `block (2 levels) in call_loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:248:in `block (2 levels) in process'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:389:in `ensure_connected'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:238:in `block in process'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:325:in `logging'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:237:in `process'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:145:in `block in call_loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:300:in `with_socket_timeout'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:144:in `call_loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/subscribe.rb:44:in `subscription'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/subscribe.rb:14:in `subscribe'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:3507:in `_subscription'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:2326:in `block in subscribe'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:69:in `block in synchronize'
web_1 | from /usr/local/lib/ruby/2.7.0/monitor.rb:202:in `synchronize'
web_1 | from /usr/local/lib/ruby/2.7.0/monitor.rb:202:in `mon_synchronize'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:69:in `synchronize'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:2325:in `subscribe'
web_1 | from /usr/local/bundle/gems/actioncable-6.0.3.1/lib/action_cable/subscription_adapter/redis.rb:84:in `block in listen'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:313:in `with_reconnect'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:75:in `block in with_reconnect'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:69:in `block in synchronize'
web_1 | from /usr/local/lib/ruby/2.7.0/monitor.rb:202:in `synchronize'
web_1 | from /usr/local/lib/ruby/2.7.0/monitor.rb:202:in `mon_synchronize'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:69:in `synchronize'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:74:in `with_reconnect'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:81:in `without_reconnect'
web_1 | from /usr/local/bundle/gems/actioncable-6.0.3.1/lib/action_cable/subscription_adapter/redis.rb:81:in `listen'
web_1 | from /usr/local/bundle/gems/actioncable-6.0.3.1/lib/action_cable/subscription_adapter/redis.rb:155:in `block in ensure_listener_running'
web_1 | /usr/local/bundle/gems/redis-4.2.5/lib/redis/connection/ruby.rb:63:in `block in _read_from_socket': Connection reset by peer (Errno::ECONNRESET)
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/connection/ruby.rb:52:in `loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/connection/ruby.rb:52:in `_read_from_socket'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/connection/ruby.rb:45:in `gets'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/connection/ruby.rb:378:in `read'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:280:in `block in read'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:268:in `io'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:279:in `read'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:147:in `block (3 levels) in call_loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:146:in `loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:146:in `block (2 levels) in call_loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:248:in `block (2 levels) in process'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:389:in `ensure_connected'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:238:in `block in process'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:325:in `logging'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:237:in `process'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:145:in `block in call_loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:300:in `with_socket_timeout'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:144:in `call_loop'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/subscribe.rb:44:in `subscription'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/subscribe.rb:14:in `subscribe'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:3507:in `_subscription'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:2326:in `block in subscribe'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:69:in `block in synchronize'
web_1 | from /usr/local/lib/ruby/2.7.0/monitor.rb:202:in `synchronize'
web_1 | from /usr/local/lib/ruby/2.7.0/monitor.rb:202:in `mon_synchronize'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:69:in `synchronize'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:2325:in `subscribe'
web_1 | from /usr/local/bundle/gems/actioncable-6.0.3.1/lib/action_cable/subscription_adapter/redis.rb:84:in `block in listen'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis/client.rb:313:in `with_reconnect'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:75:in `block in with_reconnect'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:69:in `block in synchronize'
web_1 | from /usr/local/lib/ruby/2.7.0/monitor.rb:202:in `synchronize'
web_1 | from /usr/local/lib/ruby/2.7.0/monitor.rb:202:in `mon_synchronize'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:69:in `synchronize'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:74:in `with_reconnect'
web_1 | from /usr/local/bundle/gems/redis-4.2.5/lib/redis.rb:81:in `without_reconnect'
web_1 | from /usr/local/bundle/gems/actioncable-6.0.3.1/lib/action_cable/subscription_adapter/redis.rb:81:in `listen'
web_1 | from /usr/local/bundle/gems/actioncable-6.0.3.1/lib/action_cable/subscription_adapter/redis.rb:155:in `block in ensure_listener_running'
nulimit-web_web_1 exited with code 1
这是redis服务器的输出:
1:M 08 Dec 2020 20:03:00.438 - Client closed connection
暂无答案!
目前还没有任何答案,快来回答吧!