estately / rets

A pure-ruby library for fetching data from RETS servers
https://github.com/estately/rets
127 stars 94 forks source link

Status 407 When Using a Proxy #208

Closed Siggs2000 closed 7 years ago

Siggs2000 commented 7 years ago

Doing a bunch of different rets mappings this week....

I ran into one that requires a proxy and I'm getting an HTTP error when logging in. My code:

@client = Rets::Client.new({
    metadata_serializer: Rets::Metadata::JsonSerializer.new,
    login_url: @login_url,
    http_proxy: "http://proxy:stuff_here@proxy-54-83-47-43.proximo.io",
    username: @username,
    password: @password
    })

The proxy service doesn't require a password (or it's actually included in the url itself or something)

It returns this error:

Rets::HttpError: HTTP status: 407, body: invalid
    from /app/vendor/bundle/ruby/2.3.0/gems/rets-0.10.0/lib/rets/parser/error_checker.rb:50:in `check'
    from /app/vendor/bundle/ruby/2.3.0/gems/rets-0.10.0/lib/rets/http_client.rb:62:in `http_get'
    from /app/vendor/bundle/ruby/2.3.0/gems/rets-0.10.0/lib/rets/client.rb:333:in `http_get'
    from /app/vendor/bundle/ruby/2.3.0/gems/rets-0.10.0/lib/rets/client.rb:31:in `login'
    from (irb):45
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.7/lib/rails/commands/console.rb:110:in `start'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.7/lib/rails/commands/console.rb:9:in `start'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.7/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.7/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.7/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:8:in `require'
    from bin/rails:8:in `<main>'
Siggs2000 commented 7 years ago

This MLS also requires a User Agent and User Agent Password, btw... Is this the proper syntax for that?

@client = Rets::Client.new({
    metadata_serializer: Rets::Metadata::JsonSerializer.new,
    login_url: @login_url,
    username: @username,
    password: @password,
    agent:@user_agent,
    ua_password:@ua_password})
dougcole commented 7 years ago

That all looks correct to me, I'm not sure why the MLS is returning a 407, sorry! You can pass in a logger when initializing the client, I'd start by passing in a logger and seeing the full response from the MLS, something like logger: Logger.new(STDOUT)

dougcole commented 7 years ago

I'm going to close this, as it sounds like it's probably an issue with the rets server, not with the rets gem specifically. Feel free to post back to this issue if you have more questions or want help looking at the log output.

Siggs2000 commented 7 years ago

It might actually be the proxy that I'm using. I've tried this on other MLS system and I get the same error. I'll check with Proximo.

I also figured out the useragent password syntax too. I'll add an example PR for that too. Thanks again.