I'm trying to use NORD VPN proxy to make a request in ruby. The proxy is good, I've tested it successfully with curl as well as in a python script.
However, I'm not able to make it work in ruby and I suspect it has to do with the odd port (89) used in the proxy since I've done this successfully in ruby before using port 80.
Any advice is welcome, hopefully you're able to point out a flaw in my code!
require "uri"
require 'net/http'
proxy_host = 'no179.nordvpn.com'
proxy_port = 89
proxy_user = 'user'
proxy_pass = 'pass'
uri = URI.parse("https://api.ipify.org/")
proxy = Net::HTTP::Proxy(proxy_host, proxy_port, proxy_user, proxy_pass)
req = Net::HTTP::Get.new(uri.path)
result = proxy.start(uri.host, uri.port) do |http|
http.request(req)
end
Error:
3.0.2/lib/ruby/gems/3.0.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:227:in 'rbuf_fill': end of file reached (EOFError)
As a side note I felt it worth mentioning I've tried the following http clients with the same results:
- HTTParty (same error)
- Faraday (same error)
- http.rb
3.0.2/lib/ruby/gems/3.0.0/gems/http-5.0.4/lib/http/connection.rb:108:in 'read_headers!': couldn't read response headers (HTTP::ConnectionError)
Ruby version: 3.0.2