0
我有一个初始化程序启动xmpp4r客户端。当我将Puma服务器作为常规进程运行时,它工作正常。但是当我启动puma作为守护进程(-d选项)时,它会运行几秒钟并断开与xmpp服务器的连接。我有单独的线程来处理重新连接,但当puma是守护进程时它不起作用。Rails + xmpp4r + puma。 Whem puma作为守护进程运行XMPP断开连接
def init_reconnection_timer
timers = Timers::Group.new
periodic_timer = timers.every(5) do
if @client.is_disconnected?
begin
Rails.logger.info "XmppConnector ##### reconnecting to #{APP_CONFIG['broker_address']} ..."
connect
Rails.logger.info "XmppConnector ##### connected!"
presence
rescue
end
end
end
Thread.new do
loop do
timers.wait
end
end
end
我在puma是守护进程的日志里没有任何东西。 在Rails应用程序启动后,它可以工作几秒钟,像往常一样接收消息,智商,没有错误。然后静静地断开连接。这是我的班级的构造:
class XmppConnector
include Singleton
def initialize
@jid = Jabber::JID::new(APP_CONFIG['broker_username'] + '@' + APP_CONFIG['broker_address'])
@jid.resource='rails'
@client = Jabber::Client::new(@jid)
connect
init_presence_callback
init_message_callback
init_iq_callback
init_reconnection_timer
init_subscription_requests
presence
@protocol_interface = RemoteInterface.new
Rails.logger.info "XmppConnector ##### initialized"
end
但是,当美洲狮运行没有-d选项 - 没有问题。在开发和生产中,我的工作站和服务器也是如此。 红宝石2.0.0 彪马2.9.2闵线:0,最大线程数:16个 轨4.2.0beta4