Closed whatupdave closed 13 years ago
Is this ok?
Sorry I missed the changed code. Looks good - thanks very much!
How do I close the connection? I have tried calling close_connection
on EventMachine::Hiredis::Client
with no success.
Here is my code:
require 'rubygems'
require 'eventmachine'
require 'em-websocket'
require 'em-hiredis'
EM.epoll
EM::Hiredis.logger
puts "Total descriptors: #{EM.set_descriptor_table_size(10230)}"
EM.run do
socket = EM::WebSocket.start(:host => "0.0.0.0", :port => "8080") do |ws|
ws.onopen do
@subscriber = EM::Hiredis.connect('redis://127.0.0.1:6379/0')
@publisher = EM::Hiredis.connect('redis://127.0.0.1:6379/0')
end
ws.onclose do
puts "Websocket: closed"
@publisher.close_connection
@subscriber.close_connection
end
end
end
After onclose I get "Websocket: closed" printed on screen but when looking at redis-server log the two connections remains open.
[7375] 17 Oct 15:48:11 - 2 clients connected (0 slaves), 940192 bytes in use
Ok, my fault. I forgot to add require 'bundler/setup
so the wrong version was being load.
Great gem.
This lets you close the connection to redis