Closed philgyford closed 11 years ago
I've got it... EventMachine::Twitter::Connection.on_body()
starts like this:
def on_body(data)
begin
@buffer.extract(data).each do |line|
handle_stream(line)
end
...
And data
looks something like this:
"{\"control\":{\"control_uri\":\"/1.1/site/c/1_224090_e1c4219ef18ffbe610b8267ce33ab3f1\"}}\r\n\r\n"
Extra linebreaks on the end. So handle_stream(line)
gets called twice, and the second time line
is "\n"
. So I guess handle_stream()
is outputting the same response on both occasions. But it should only be called once.
I'm not sure how best to fix this. Is doing data.strip!
in on_body()
a stupid idea? It seems too simple and easy :)
Thanks for tracking this down!
I haven't had reports of this so it appears to be sitestream specific. That makes some sense as few people have sitestream credentials so it probably hasn't tripped many people up.
This should be an easy fix, we just need to strip off the newlines before handing off the response to handle_stream
. Will hopefully have a fix out soon.
Great! Once again, let me know if there's any way I can help try things, given we have Site Stream access.
I just pushed a fix, if possible, could you verify it works by pointing to master. If all good, I'll get a release out ASAP.
Yes, that seems to work, thanks!
One issue for me - tweetstream currently specifies em-twitter '~> 0.2'
. Will that change to 0.3 soon or are there reasons not to?
I'm going to be releasing a new tweetstream gem in tandem with em-twitter so you won't be caught in dependency hell. :smile:
That'll be great, thanks :) Any idea of the timeframe? Days or weeks? Not trying to hassle you at all, just so that I have a vague idea.
@philgyford If you want to use the latest code in your project, you don’t need to wait for a gem release. You can just add the following line to your Gemfile
:
gem 'em-twitter', :git => 'https://github.com/tweetstream/em-twitter.git'
But tweetstream will still use em-twitter 0.2.x won't it? (I may have misunderstood how this works.)
The latest gem release of tweetstream
(currently version 2.5.0) specifies the following dependency on em-twitter
: ~> 0.2
.
This this is the same as saying any version greater than or equal to 0.2 but less than 1. This includes 0.3, 0.3.1, 0.4, 0.10, and 0.99.999. As long as the first digit is a zero and the second digit is greater than or equal to 2, the constraint will be met.
When you see the pessimistic version constraint (~>
), replace the last digit specified with an x, where x is greater than or equal to that number. So, for example:
~> 0.2
means any version 0.x where x is greater than or equal to 2.~> 0.2.0
means any version 0.2.x where x is greater than or equal to 0.Give it a try and let me know if it’s not working the way you expected. You can confirm that it’s working as expected by inspecting your Gemfile.lock
.
Ah, I think I misunderstood the syntax. Thanks; I think it's working for me now!
When using Twitter Site Streams, I seem to be getting all events twice. I connect like this:
And get results like this:
And the same for receiving messages etc.
Out of curiosity I tried replacing the
path
andparams
with these from the em-twitter example:and the same thing happened... until I removed this line:
Then I only received one event for each occurrence of 'yankees'.
It's possible this is some weird Twitter Site Streams thing, rather than em-twitter. But I'm not sure how to test any closer to Twitter, and am struggling to narrow it down any further. Any suggestions for isolating this more?