简体   繁体   English

如何从机架中间件内部访问Thin :: Connection?

[英]How do I access Thin::Connection from inside rack middleware?

I would like to run set_comm_inactivity_timeout(0) on my EM Connection from inside Rack Middleware. 我想从机架中间件内部的EM连接上运行set_comm_inactivity_timeout(0)

This will allow me to have one timeout for my upgraded web sockets and another for the rails app. 这将使我的升级Web套接字有一个超时,而Rails应用程序有一个超时。

My web sockets are all first in the middleware chain so it is not wreaking havoc with Rack::Lock and such. 我的Web套接字在中间件链中都是第一位的,因此不会对Rack :: Lock等造成严重破坏。

I see that some simply go for an infinite timeout in Thin and then inject something like Rack::Timeout after. 我看到有些只是在Thin中进行无限超时,然后在之后注入Rack :: Timeout之类的东西。

Is there a way to access EM::Connection or the signature of the connection from Rack middleware? 有没有办法从Rack中间件访问EM :: Connection或连接的签名?

Only way to do this is monkey patch thin: 做到这一点的唯一方法是猴子补丁薄:

class Thin::Connection
  alias :thin_process      :process
  def process
    set_comm_inactivity_timeout(0)
    thin_process
  end
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM