{"action":"created","issue":{"url":"https://api.github.com/repos/sferik/twitter/issues/709","labels_url":"https://api.github.com/repos/sferik/twitter/issues/709/labels{/name}","comments_url":"https://api.github.com/repos/sferik/twitter/issues/709/comments","events_url":"https://api.github.com/repos/sferik/twitter/issues/709/events","html_url":"https://github.com/sferik/twitter/issues/709","id":95960554,"number":709,"title":"Change to HTTP gem dependency breaks Twitter::Streaming::Connection v6","user":{"login":"davebell","id":2377840,"avatar_url":"https://avatars.githubusercontent.com/u/2377840?v=3","gravatar_id":"","url":"https://api.github.com/users/davebell","html_url":"https://github.com/davebell","followers_url":"https://api.github.com/users/davebell/followers","following_url":"https://api.github.com/users/davebell/following{/other_user}","gists_url":"https://api.github.com/users/davebell/gists{/gist_id}","starred_url":"https://api.github.com/users/davebell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davebell/subscriptions","organizations_url":"https://api.github.com/users/davebell/orgs","repos_url":"https://api.github.com/users/davebell/repos","events_url":"https://api.github.com/users/davebell/events{/privacy}","received_events_url":"https://api.github.com/users/davebell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"stve","id":28044,"avatar_url":"https://avatars.githubusercontent.com/u/28044?v=3","gravatar_id":"","url":"https://api.github.com/users/stve","html_url":"https://github.com/stve","followers_url":"https://api.github.com/users/stve/followers","following_url":"https://api.github.com/users/stve/following{/other_user}","gists_url":"https://api.github.com/users/stve/gists{/gist_id}","starred_url":"https://api.github.com/users/stve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stve/subscriptions","organizations_url":"https://api.github.com/users/stve/orgs","repos_url":"https://api.github.com/users/stve/repos","events_url":"https://api.github.com/users/stve/events{/privacy}","received_events_url":"https://api.github.com/users/stve/received_events","type":"User","site_admin":false},"milestone":null,"comments":11,"created_at":"2015-07-20T00:04:13Z","updated_at":"2016-01-13T20:04:45Z","closed_at":null,"body":"The HTTP (gem) dependency has changed from **~> 0.6.0** for v5.14.0 to **~> 0.8.3** for v6.0.0.\r\n\r\nThere's been a change to how the HTTP gem creates request object URIs. The former uses `<URI>` while the latter uses `<HTTP::URI>` which is a subclass of `<Addressable::URI>`:\r\n\r\n**0.6.x**\r\n```ruby\r\n@uri    = uri.is_a?(URI) ? uri : URI(uri.to_s)\r\n```\r\n**0.8.x**\r\n```\r\n@uri    = HTTP::URI.parse(uri).normalize\r\n```\r\nThe **0.8.x** `HTTP::URI.parse` method does not set the port based on the uri scheme:\r\n\r\n**0.6.x**\r\n```ruby\r\n[38] pry(main)> uri = URI('https://stream.twitter.com')\r\n=> #<URI::HTTPS:0x007fa54f8d38e8 URL:https://stream.twitter.com>\r\n[39] pry(main)> uri.port\r\n=> 443\r\n```\r\n**0.8.x**\r\n```ruby\r\n[40] pry(main)> uri = HTTP::URI.parse('https://stream.twitter.com').normalize\r\n=> #<Addressable::URI:0x3fd2a57bd650 URI:https://stream.twitter.com/>\r\n[41] pry(main)> uri.port\r\n=> nil\r\n```\r\nAs a result, when creating a [`Twitter::Streaming::Connection`](https://github.com/sferik/twitter/blob/master/lib/twitter/streaming/connection.rb) with **0.8.x**, the TCPSocket is passed `nil` for the port argument.\r\n\r\n```ruby\r\nmodule Twitter\r\n  module Streaming\r\n    class Connection\r\n      attr_reader :tcp_socket_class, :ssl_socket_class\r\n\r\n      def initialize(options = {})\r\n        @tcp_socket_class = options.fetch(:tcp_socket_class) { TCPSocket }\r\n        @ssl_socket_class = options.fetch(:ssl_socket_class) { OpenSSL::SSL::SSLSocket }\r\n      end\r\n\r\n      def stream(request, response)\r\n        client_context = OpenSSL::SSL::SSLContext.new\r\n        client         = @tcp_socket_class.new(Resolv.getaddress(request.uri.host), request.uri.port) #<-- Port is not being set\r\n        ssl_client     = @ssl_socket_class.new(client, client_context)\r\n\r\n        ssl_client.connect\r\n        request.stream(ssl_client)\r\n        while body = ssl_client.readpartial(1024) # rubocop:disable AssignmentInCondition, WhileUntilModifier\r\n          response << body\r\n        end\r\n      end\r\n    end\r\n  end\r\nend\r\n```\r\nThis results in either a failed connection on OS X or a connection timeout on Linux.\r\n\r\n**OS X 10.10.4**\r\n```\r\nErrno::EADDRNOTAVAIL: Can't assign requested address - connect(2) for \"199.16.156.217\" port \r\nfrom /ruby/2.1.4/lib/ruby/gems/2.1.0/bundler/gems/twitter-a35bf7cc6b69/lib/twitter/streaming/connection.rb:17:in `initialize'\r\n```\r\n\r\n**Ubuntu 14.04**\r\n```\r\nErrno::ETIMEDOUT: Connection timed out - connect(2) for \"199.16.156.20\" port \r\nfrom /ruby/2.1.4/bundler/gems/twitter-a35bf7cc6b69/lib/twitter/streaming/connection.rb:17:in `initialize'\r\n```"},"comment":{"url":"https://api.github.com/repos/sferik/twitter/issues/comments/171417019","html_url":"https://github.com/sferik/twitter/issues/709#issuecomment-171417019","issue_url":"https://api.github.com/repos/sferik/twitter/issues/709","id":171417019,"user":{"login":"daturkel","id":1828387,"avatar_url":"https://avatars.githubusercontent.com/u/1828387?v=3","gravatar_id":"","url":"https://api.github.com/users/daturkel","html_url":"https://github.com/daturkel","followers_url":"https://api.github.com/users/daturkel/followers","following_url":"https://api.github.com/users/daturkel/following{/other_user}","gists_url":"https://api.github.com/users/daturkel/gists{/gist_id}","starred_url":"https://api.github.com/users/daturkel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daturkel/subscriptions","organizations_url":"https://api.github.com/users/daturkel/orgs","repos_url":"https://api.github.com/users/daturkel/repos","events_url":"https://api.github.com/users/daturkel/events{/privacy}","received_events_url":"https://api.github.com/users/daturkel/received_events","type":"User","site_admin":false},"created_at":"2016-01-13T20:04:45Z","updated_at":"2016-01-13T20:04:45Z","body":"This commit fixes it, but I don't believe it's been merged? https://github.com/animeavi/twitter/commit/6d08c5932d3033d5b69537730e02ac5905775410"}}