-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP::Parser::Error: Could not parse data entirely (EDIT: with a fix) #27
Comments
Just realized that the first line in the code I maintain was doing a bit of monkey patching: module Twitter
class JSONStream < EventMachine::Connection
attr_reader :options
end
end My guess is that the use case may not be currently supported by the gem, then. I'll dive more and see if I can make this work somehow. Any hint welcome if you read this! |
The parser needs to be reset in case of reconnection, or you'll get a HTTP::Parser::Error.
Figured out: on reconnect, the I made a fix that works for me, although beware, I'm only discovering this gem so there will be a better way IMO. https://github.com/thbar/twitter-stream/compare/fix-for-27-could-not-parse-data-entirely How to use: Signal.trap('USR1') do
@should_restart = true
end
EventMachine::add_periodic_timer(1) do
if @should_restart
tracked = get_updated_keywords.map { |e| CGI.escape(e) }.join(',')
stream.reconnect_with_updated_config do |options|
options[:content] = "track=#{tracked}"
end
@should_restart = false
end
end Let me know if you find a better way to do this. |
So how does one use this again? Just put in that code anywhere and it runs? |
n'thing tibbon: can you provide some examples of a configuration or implementation of this fix or is this something that is going to be included in a release of the gem? |
@tibbon see my sample above; basically you need a way to detect you need to change the keywords (for my customer's app here I used a signal because it was convenient to inform the program from outside), then use Hope this helps! |
The parser needs to be reset in case of reconnection, or you'll get a HTTP::Parser::Error.
Tested against master today - when I do this to change what I track:
I get this error (after 2 on_reconnect calls):
I updated to master and it still applies.
Does anyone else meet this issue?
The text was updated successfully, but these errors were encountered: