Skip to content

Conversation

@aburnheimer
Copy link

(First pull request. Apologize for the over-verbosity.)

To resolve #35 seen where EventMachine.bind_connect would fail to create a connection through a Squid web proxy. At worst, this just allows an alternative to what bgreenlee proposed in #2.

Problem:
voloko:twitter-stream (0.1.16), options calling JSONStream::connect

{:auth=>"1234567890abcdef1234567890abcdef12345678:X",
 :host=>"streaming.campfirenow.com",
 :proxy=>"http://proxy.domain.com:3128",
 :path=>"/room/123456/live.json"}

voloko:twitter-stream (0.1.16), options inside of JSONStream::connect

[[:auth, "1234567890abcdef1234567890abcdef12345678:X"],
 [:auto_reconnect, true], [:content, ""],
 [:content_type, "application/x-www-form-urlencoded"],
 [:filters, []], [:host, "streaming.campfirenow.com"],
 [:method, "GET"], [:oauth, {}], [:params, {}],
 [:path, "/room/123456/live.json"], [:port, 443],
 [:proxy, "http://proxy.domain.com:3128"],
 [:ssl, true], [:timeout, 0], [:user_agent, "TwitterStream"]]

voloko:twitter-stream (0.1.16), JSONStream#send_request never gets called because Twitter::JSONStream.connect(options) hangs... eventually dying with "Tried 11 times to connect."

Resolution provided by this request (0.1.17), options calling JSONStream::connect

{:auth=>"1234567890abcdef1234567890abcdef12345678:X",
 :host=>"streaming.campfirenow.com",
 :proxy=>"http://proxy.domain.com:3128",
 :proxy_type=>:direct,
 :path=>"/room/123456/live.json"}

...options inside of JSONStream::connect

[[:auth, "1234567890abcdef1234567890abcdef12345678:X"],
 [:auto_reconnect, true], [:content, ""],
 [:content_type, "application/x-www-form-urlencoded"],
 [:filters, []], [:host, "streaming.campfirenow.com"],
 [:method, "GET"], [:oauth, {}], [:params, {}],
 [:path, "/room/123456/live.json"], [:port, 443],
 [:proxy, "http://proxy.domain.com:3128"],
 [:proxy_type, :direct], [:ssl, true], [:timeout, 0],
 [:user_agent, "TwitterStream"]]

...by the time JSONStream::connect finishes, host, options[:host], port, and options[:port] are overwritten to things that allow EventMachine.bind_connect to work.

JSONStream#send_request is called, and options looks as such at the bottom

[[:auth, "1234567890abcdef1234567890abcdef12345678:X"],
 [:auto_reconnect, true], [:content, ""],
 [:content_type, "application/x-www-form-urlencoded"], [:filters, []],
 [:host, "proxy.domain.com"], [:method, "GET"], [:oauth, {}],
 [:params, {}], [:path, "https://streaming.campfirenow.com/room/123456/live.json"],
 [:port, 3128], [:proxy, nil], [:proxy_type, :direct], [:ssl, false],
 [:timeout, 0], [:user_agent, "TwitterStream"]]

..., headers at bottom of JSONStream#send_request

["GET https://streaming.campfirenow.com/room/123456/live.json HTTP/1.1",
 "Host: streaming.campfirenow.com", "Accept: */*",
 "User-Agent: TwitterStream",
 "Authorization: Basic ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRST",
 "\r\n"]

Andrew Burnheimer and others added 3 commits December 2, 2012 16:26
To resolve voloko#35 seen where
EventMachine.bind_connect would fail to create a connection through a
Squid web proxy.  At worst, this allows an alternative to what bgreenlee
proposed in voloko#2.
@MarcoSero
Copy link

I can't get the proxy working. Can anyone maybe merge this if it solves the problem?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like the same condition twice, accidental duplication, or is this intentional?

@rud
Copy link
Contributor

rud commented Jan 7, 2015

This does not look too scary, what's the thinking, anybody want to see this merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem working with Squid web proxy

3 participants