【问题标题】:Rails + xmpp4r + puma. Whem puma run as daemon XMPP disconnectsRails + xmpp4r + puma。 Whem puma 作为守护进程运行 XMPP 断开连接
【发布时间】:2015-02-03 05:35:15
【问题描述】:

我有一个启动 xmpp4r 客户端的初始化程序。当我将 puma 服务器作为常规进程运行时,它工作正常。但是当我将 puma 作为守护程序(-d 选项)启动时,它会工作几秒钟并与 xmpp 服务器断开连接。我有单独的线程来处理重新连接,但是当 puma 是守护进程时它不起作用。

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应用程序启动后,它会运行几秒钟,接收消息,iqs,像往常一样没有错误。然后默默断开。这是我的类的构造函数:

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

但是当 puma 在没有 -d 选项的情况下运行时 - 完全没有问题。在开发和生产中,我的工作站和服务器也是如此。 红宝石 2.0.0 puma 2.9.2 最小线程:0,最大线程:16 轨道 4.2.0beta4

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-4 xmpp puma xmpp4r


    【解决方案1】:

    puma 中有一个关于初始化程序线程的错误,现在它已修复 https://github.com/puma/puma/issues/617

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-17
      • 1970-01-01
      • 1970-01-01
      • 2023-03-02
      • 2015-10-26
      • 2016-11-09
      相关资源
      最近更新 更多