Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Over Query Limit - heroku #222

Closed
piotrmasior opened this Issue · 17 comments

7 participants

@piotrmasior

Background of this issue, please read :
http://stackoverflow.com/questions/6766222/google-maps-v3-api-over-query-limit-but-just-1-request

What is that mean? Because it sounds like gem started to be useless since v3 Google API for Heroku users.
Can only say that I cannot pass any API key, as V3 API started to reject everything that posses &key=xxx.

Is there any other workaround despite mentioned pure JavaScript solution for shared hosting?

@alexreisner
Owner

You should not be passing an API key unless you're using Google Premier.

@piotrmasior

Ok... I know that... so what else than buy Google Premiere I can do ?

@alexreisner
Owner

Just don't use an API key and you should be fine. Are you actually having problems on Heroku? I have a couple of Geocoder apps on Heroku that work. rubygeocoder.com is actually on Heroku.

@piotrmasior

Invoked a few factories, has got address validation via geocoder:

The address you passed seems invalid, status was: OVER_QUERY_LIMIT.
        Request was: http://maps.googleapis.com/maps/api/geocode/json?language=en&address=Vermont, New Kylee, 27013 Cedrick Valleys&sensor=false
rake aborted!
Validation failed: Address invalid

@alexreisner
Owner

Hmmm...if this is indeed related to the way Google counts geocoding requests from shared IP addresses I think it's pretty obvious there's nothing Geocoder can do about it. If you really need it to work on Heroku you might need to pay for Google Premier. Or pay for hosting with a dedicated IP address.

@piotrmasior

this is what I was afraid about. Thanks for your time. Best

@kurioscreative

I ran into the same problem (using heroku as well), and moved the geocode step from the backend(ruby) to the frontend(javascript). Not much you can do about it from server side, but you can pass in the location to the google maps api library. Here is a gist with my solution: https://gist.github.com/3398483. It will geocode and pass in the coordinates to a hidden field on a form using the user ip instead of server.

Some links that I found helpful:
https://developers.google.com/maps/documentation/geocoding/#Limits
http://stackoverflow.com/questions/6451099/using-geocoder-on-production-server
https://developers.google.com/maps/articles/geocodestrat
https://developers.google.com/maps/documentation/javascript/tutorial#Loading_the_Maps_API

@kevinhq

I ran the similar problems.
The application I developed (hosted on Heroku platform too) , currently calling distance_to method on its model.
Since it calls that method inside a looping block (based on the current data), there's a time where I saw that method returns "" (from the rescue block).

When it returns nil, I saw this on Heroku logs :
2013-01-23T12:44:48+00:00 app[web.1]: Google Geocoding API error: over query limit.
2013-01-23T12:44:48+00:00 app[web.1]: "=====================DISTANCE======================="
2013-01-23T12:44:48+00:00 app[web.1]: ""
2013-01-23T12:44:48+00:00 app[web.1]: "=====================DISTANCE======================="

Any work around to solve this problem ? Beside buying anything of course...

@timrwilliams

I've setup QuotaGuard to deal with this type of problem on Heroku. Its not free but guarantees your quota limits without having to setup your own infrastructure. I'm using it with Ruby Geocoder and its just one line of config to get started.

@alexreisner
Owner

@timrwilliams thanks!

@kastman

This may fall into the "so stupid it's smart" category, but I think I have a solution to the query limit on shared IP systems like Heroku.

On the Google Geocoder API documentation, there's a note about https:

Note: HTTPS is enforced for requests that include an API key.

Without ssl, I get a 'request denied' error. But when I :use_https in config/initializers/geocoder.rb:

Geocoder.configure(
    :api_key => ENV['GEOCODER_API_KEY'],
    :use_https => true
)

... there are no errors and my requests are correctly attributed to my own API key in the Google API console, even when deployed on heroku.

Hope that works for other people too.

@kastman

Yes, :use_https only sets the protocol that Geocoder makes its API requests on, not the protocol that your app is served over.

@kastman

You can use that :api_key config for the free version, too; I'm only using the free version like you.

I think API keys for google have been centralized now at: https://code.google.com/apis/console

@ToniTornado

@kastman Thanks a lot, I have exactly the same problem. But as soon as I set use_https to true, I get this error:

IOError at addresses/5
use_ssl value changed, but session already started

Any idea on this?

@kastman

@ToniTornado Hmm, looks like use_ssl persists between requests and may not like to be changed after first initialization. Are you setting ssl options anywhere else (possibly mail initializers, etc.)? You may have to stick to either on or off (when in doubt, using ssl with everything is a good bet). I'd look through any other library code that you may have initialized for that app in particular and see if you can find where ssl is being set.

Otherwise, maybe you're not initializing early enough or in the right spot, and Rails is being overly-eager with something? Sorry, but it's been a while since I dug into rails internals and I can't point in a more specific direction. I wonder why this would throw an IOError - that seems curious.

@alexreisner
Owner

@ToniTornado, @kastman I believe this was fixed by #592, which will be part of the next gem release.

@ToniTornado

Thank you both very much, since I point to the master in my gemfile it works like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.