firehoseio / firehose

Build realtime Ruby web applications. Created by the fine folks at Poll Everywhere.
http://firehose.io/
MIT License
727 stars 72 forks source link

Firehose hangs when couple of browser's tab are opened at the same time #73

Open qrooel opened 6 years ago

qrooel commented 6 years ago

Hi,

Imagine I have 3 Google Chrome/Firefox browser tab opened at once, every on the same page using Firehose. When I want to open fourth tab (on the same page) - it hangs and loading time is like 20 seconds. If I close third tab before fourth is fully loaded - it loads instantly. So connections block themselves somehow. I tried to run Rainbows! on 4 processes, but it doesn't help.

In my network tab I see websocketschannels@firehose, xhr, which gets 204 status after ~20s - I figured that's OK. Is is possible that browser blocks too many connections?

Stack: Firehose 1.4.0, Rainbows! 5.1.1 [no errors in logs], Apache 2.4.25 [no errors in apache logs] config:

ProxyPassMatch /websockets http://localhost:7474 Keepalive=On acquire=3000 timeout=600
ProxyPassReverse /websockets http://localhost:7474

How I use Firehose:

   new Firehose.MultiplexedConsumer(
        uri: websocket_host_no_protocol
        ssl: true
        channels:
          "some-channel-path":
            message: (msg) ->
              someMethod(msg)
      ).connect()

Rainbows logs:

[2017-10-03 15:18:17.989 #6669] DEBUG : HTTP multiplexing POST, subscribing [{:channel=>"/websockets/entry-models-2877/new-sensor-data", :last_message_sequence=>1}, {:channel=>"/websockets/activities-1/new-important-activity", :last_message_sequence=>0}]
[2017-10-03 15:18:17.990 #6669] DEBUG : No messages in buffer, subscribing. sequence: `0` consumer_sequence: 1
[2017-10-03 15:18:17.990 #6669] DEBUG : No messages in buffer, subscribing. sequence: `0` consumer_sequence: 0
[2017-10-03 15:18:18.370 #6669] DEBUG : HTTP published "{\"entry_model_id\":2935}" to "/websockets/entry-models-2935/new-sensor-data" with ttl "2"
[2017-10-03 15:18:18.371 #6669] DEBUG : Redis stored/published `{"entry_model_id":2935}` to list `firehose:/websockets/entry-models-2935/new-sensor-data:list` with sequence `1`
[2017-10-03 15:18:18.871 #6755] DEBUG : HTTP multiplexing POST, subscribing [{:channel=>"/websockets/user-23/update-notification-icon", :last_message_sequence=>0}, {:channel=>"/websockets/hierarchy-tree-23/refresh-node", :last_message_sequence=>0}, {:channel=>"/websockets/hierarchy-tree-23/remove-node", :last_message_sequence=>0}, {:channel=>"/websockets/entry-model-undefined/update-progress-table", :last_message_sequence=>0}, {:channel=>"/websockets/entry-model-undefined/refresh-entry-model", :last_message_sequence=>0}, {:channel=>"/websockets/entry-model-undefined/refresh-trans-table", :last_message_sequence=>0}, {:channel=>"/websockets/entry-model-undefined/refresh-trans-csv", :last_message_sequence=>0}, {:channel=>"/websockets/entry-model-undefined/refresh-transformation", :last_message_sequence=>0}]
[2017-10-03 15:18:18.872 #6755] DEBUG : No messages in buffer, subscribing. sequence: `0` consumer_sequence: 0
[2017-10-03 15:18:18.872 #6755] DEBUG : No messages in buffer, subscribing. sequence: `0` consumer_sequence: 0
[2017-10-03 15:18:18.872 #6755] DEBUG : No messages in buffer, subscribing. sequence: `0` consumer_sequence: 0
[2017-10-03 15:18:18.872 #6755] DEBUG : No messages in buffer, subscribing. sequence: `0` consumer_sequence: 0
[2017-10-03 15:18:18.872 #6755] DEBUG : No messages in buffer, subscribing. sequence: `0` consumer_sequence: 0
[2017-10-03 15:18:18.872 #6755] DEBUG : No messages in buffer, subscribing. sequence: `0` consumer_sequence: 0
[2017-10-03 15:18:18.872 #6755] DEBUG : No messages in buffer, subscribing. sequence: `0` consumer_sequence: 0
[2017-10-03 15:18:18.872 #6755] DEBUG : No messages in buffer, subscribing. sequence: `0` consumer_sequence: 0
[2017-10-03 15:18:19.621 #6755] DEBUG : Clearing old metrics

I have no idea how to deal with this. I would be grateful for any help!

Edit: Propably problem with apache configuration, ws request should get 101 status instead of 200.

thoughtless commented 6 years ago

I'm not exactly sure what is happening. You could try without Apache, just in case that is the issue. I have never used Apache with websockets, so I'm not sure what that config would need to look like.

You mention using 3 tabs that work, but I only see 2 HTTP multiplexing POST entries in the Rainbows logs. Are there more logs somewhere?

Ultimately you need to identify where the connection is getting blocked. It could be the browser, Apache, or Rainbows. Seeing the full logs from all three might help narrow it down.