firehoseio / firehose

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

Message arrives after reloading page #16

Closed heygambo closed 11 years ago

heygambo commented 11 years ago

I'm doing some tests with firehose and found something I cannot solve.

In the Keynote you say that you use rabbitMQ which queues messages in order to send them after a reconnect.

This doesn't seems to work for me, as the exact same message arrives after every page reload for 2h now.

Can I turn off this "feature"?

message arrives after refresh

Thx for helping me out

thoughtless commented 11 years ago

I think that Keynote presentation is out-of-date. Firehose uses redis as its backend, not RabbitMQ.

If I recall correctly, Firehose will send the current version on a reconnect that is made via websockets. A reconnect made via HTTP Long Polling (if it includes the appropriate "last message" query string param) will pick up where it left off.

I could be mistaken though. I haven't look at that code for a while.

bradgessler commented 11 years ago

@thoughtless is correct. Firehose expects a sequence number back from the client since it hangs on to the past n messages (can't remember what n is off the top of my head, or how that's configured).

You can disable this behavior by setting the TTL for a published message to 0.

https://github.com/polleverywhere/firehose/blob/master/lib/firehose/producer.rb#L42-L59

This instructs Redis to expire the values immediately.

So something like

Firehose::Producer.new.publish("hey there stinky").to("/my/channel", :ttl => 0)

Should get the behavior you're looking for. Let me know if otherwise.

heygambo commented 11 years ago

Thx! I'll try it out the next time I have time for it.

bradgessler commented 11 years ago

ttl configuration. Case closed.