When using eventmachine with sinatra, how can I close one http connection without closing them all?

The problem is that Twitter closes one connection once you open a second one. Try running curl https://USER:[email protected]. Com/1/statuses/filter.

Json? Track=bar in two terminals at the same time Also, while trying to figure out what is wrong, I did a rather small refactoring to improve readability: require 'sinatra' require 'sinatra/streaming' require 'eventmachine' require 'em-http' require 'json' enable :logging, :dump_errors, :raise_errors template(:tweet) { ": " } get '/test/:query' do |q| stream(:keep_open) do |out| http = EM::HttpRequest. New("https://stream.twitter.Com/1/statuses/filter.

Json? Track=#{q}") EM. Next_tick do s = http.

Get :head => { 'Authorization' => ENV. Values_at('USERNAME', 'PASSWORD') } s. Callback { out.

Close } out. Callback { s. Close } s.

Errback { out. Close } out. Errback { s.

Close } buffer = "" s. Stream do |chunk| buffer 0 and @tweet'user' end end end end end.

The problem is that Twitter closes one connection once you open a second one. Try running curl https://USER:[email protected]. Com/1/statuses/filter.

Json? Track=bar in two terminals at the same time. Also, while trying to figure out what is wrong, I did a rather small refactoring to improve readability: require 'sinatra' require 'sinatra/streaming' require 'eventmachine' require 'em-http' require 'json' enable :logging, :dump_errors, :raise_errors template(:tweet) { ": " } get '/test/:query' do |q| stream(:keep_open) do |out| http = EM::HttpRequest.

New("https://stream.twitter. Com/1/statuses/filter. Json?

Track=#{q}") EM. Next_tick do s = http. Get :head => { 'Authorization' => ENV.

Values_at('USERNAME', 'PASSWORD') } s. Callback { out. Close } out.

Callback { s. Close } s. Errback { out.

Close } out. Errback { s. Close } buffer = "" s.

Stream do |chunk| buffer 0 and @tweet'user' end end end end end.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions