title: Ruby On Rails + Redis pub/sub. Application goes down after the multiple connections from one host
body: <p>task_controller.rb:</p>
  
  <pre><code>def create
    response.headers["Content-Type"] = "text/javascript"
    task = Task.create(:blahblah)
  
    if task
      data = { :type =&gt; 'task', :method =&gt; 'create', :object =&gt; task }
      $redis.publish('message.test', data.to_json)
      send_created(task)
    else
      send_error
    end
  end
  </code></pre>
  
  <p>stream_controller.rb:</p>
  
  <pre><code>def index
    response.headers['Content-Type'] = 'text/event-stream'
    redis = Redis.new
    redis.psubscribe('message.*') do |on|
      on.pmessage do |channel, pattern, data|
        response.stream.write("data: #{data}\n\n")
      end
    end
  end
  </code></pre>
  
  <p>After the second connection from the same host, application it going down, and not response to any request. Logs are clear, so I don't know how to fix this problem.</p>