Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse geocoding always fails Geocoder::ResponseParseError #333

Closed
MeijiRestored opened this issue Oct 16, 2024 · 6 comments
Closed

Reverse geocoding always fails Geocoder::ResponseParseError #333

MeijiRestored opened this issue Oct 16, 2024 · 6 comments

Comments

@MeijiRestored
Copy link

Describe the bug
All reverse geocoding tasks fail with Geocoder::ResponseParseError.

Version
0.15.4

Logs

dawarich_sidekiq  | E, [2024-10-16T16:46:54.509796 #119] ERROR -- : Error performing ReverseGeocodingJob (Job ID: d570478e-375c-4b52-92d1-f9734bd4bdaa) from Sidekiq(reverse_geocoding) in 85.58ms: Geocoder::ResponseParseError (Geocoder::ResponseParseError):
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder/lookups/base.rb:186:in `raise_error'
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder/lookups/base.rb:215:in `rescue in parse_json'
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder/lookups/base.rb:208:in `parse_json'
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder/lookups/base.rb:225:in `parse_raw_data'
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder/lookups/base.rb:196:in `fetch_data'
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder/lookups/photon.rb:23:in `results'
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder/lookups/base.rb:46:in `search'
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder/query.rb:11:in `execute'
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder.rb:22:in `search'
dawarich_sidekiq  | /var/app/app/services/reverse_geocoding/points/fetch_data.rb:15:in `call'
dawarich_sidekiq  | /var/app/app/jobs/reverse_geocoding_job.rb:9:in `perform'
...
dawarich_sidekiq  | 2024-10-16T16:46:54.512Z pid=119 tid=kj3 class=ReverseGeocodingJob jid=0b5f9987fbe98fbf38ad7928 elapsed=0.5 INFO: fail
dawarich_sidekiq  | 2024-10-16T16:46:54.513Z pid=119 tid=kj3 WARN: {"context":"Job raised exception","job":{"retry":true,"queue":"reverse_geocoding","wrapped":"ReverseGeocodingJob","args":[{"job_class":"ReverseGeocodingJob","job_id":"d570478e-375c-4b52-92d1-f9734bd4bdaa","provider_job_id":null,"queue_name":"reverse_geocoding","priority":null,"arguments":["Point",334980],"executions":0,"exception_executions":{},"locale":"en","timezone":"Europe/Brussels","enqueued_at":"2024-10-16T16:35:11.591410395Z","scheduled_at":null}],"class":"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper","jid":"0b5f9987fbe98fbf38ad7928","created_at":1729096511.5914497,"enqueued_at":1729097117.906883,"error_message":"Geocoder::ResponseParseError","error_class":"Geocoder::ResponseParseError","failed_at":1729096529.0304668,"retry_count":4,"retried_at":1729096836.6148896}}
dawarich_sidekiq  | 2024-10-16T16:46:54.513Z pid=119 tid=kj3 WARN: Geocoder::ResponseParseError: Geocoder::ResponseParseError
dawarich_sidekiq  | 2024-10-16T16:46:54.513Z pid=119 tid=kj3 WARN: app/services/reverse_geocoding/points/fetch_data.rb:15:in `call'
dawarich_sidekiq  | app/jobs/reverse_geocoding_job.rb:9:in `perform'

Additional context
Happens with both default geocoder (Nominatim) and self-hosted Photon instance (served over HTTPS from a remote server). It is happening only since the latest 0.15.4 update.

Here is an example query from my Photon instance in case it could be the issue (probably not since Nominatim fails as well):
/reverse?lon=2&lat=50

{
    "features": [
        {
            "geometry": {
                "coordinates": [
                    1.9993273,
                    49.9994663
                ],
                "type": "Point"
            },
            "type": "Feature",
            "properties": {
                "osm_id": 297408537,
                "extent": [
                    1.9961878,
                    50.0094171,
                    1.9996089,
                    49.9881855
                ],
                "country": "France",
                "city": "Bettencourt-Rivière",
                "countrycode": "FR",
                "postcode": "80270",
                "county": "Somme",
                "type": "street",
                "osm_type": "W",
                "osm_key": "highway",
                "osm_value": "tertiary",
                "name": "Cavée du Quesnoy",
                "state": "Hauts-de-France"
            }
        }
    ],
    "type": "FeatureCollection"
}
@Tazmanian79
Copy link

I can confirm this issue. No more Reverse Geocoding after update to 0.15.4
I also use the photon api

@chrisl8
Copy link
Contributor

chrisl8 commented Oct 17, 2024

What does everyone have set for their PHOTON_API_HOST variable?

I know that I had to play around with variations such as:

hostname
https://hostname
http://hostname:2322
hostname:2322
https://hostname:2322
etc.

@Freika is this possibly because of using the new Geocoder library code #300 (comment) ?

It works great for me without https using:
PHOTON_API_HOST=photon:2322

Maybe now only http works and not https?

@chrisl8
Copy link
Contributor

chrisl8 commented Oct 17, 2024

@Freika I can confirm that while it now works to contact a photon server via http, it seems unable to contact any photon server via https regardless of how I set up the PHOTON_API_HOST variable.


I think maybe the call to Geocoder needs to specify whether or not to use https now?

settings[:photon] = { host: PHOTON_API_HOST }

Changing it to this seems to make it work for HTTPS endpoints?

  settings[:photon] = { use_https: true, host: PHOTON_API_HOST }

Although please test it yourself, I'm not 100% sure.

The options for Geocoder seem to be here:
https://github.com/alexreisner/geocoder/blob/19f3cd1c717f5670aafaf690aa3b20955822ea88/lib/geocoder/configuration.rb#L53

The use_https part didn't matter/work before when Geocoder only did https, but maybe it matters now?


If that is the fix, then there will need to be more code to either parse the PHOTON_API_HOST variable for the protocol or have a 2nd variable for PHOTON_API_USE_HTTPS.

@ycsh-w
Copy link

ycsh-w commented Oct 18, 2024

I am having the same issue. I am trying to use Nominatim with REVERSE_GEOCODING_ENABLED: true but no luck. Does the fix mentioned above also help with Nominatim users?

@chrisl8
Copy link
Contributor

chrisl8 commented Oct 18, 2024

I am having the same issue. I am trying to use Nominatim with REVERSE_GEOCODING_ENABLED: true but no luck. Does the fix mentioned above also help with Nominatim users?

Yes, it should, as that is the same issue. Nominatim requires HTTPS and the current code is defaulting to HTTP with no method to force HTTPS.

Assuming my PR works and is accepted, it puts HTTPS back as the default, with an option to turn it off, so things should work again.

Freika added a commit that referenced this issue Oct 19, 2024
Add use_https option to photon call to fix Issue #333
@Freika
Copy link
Owner

Freika commented Oct 19, 2024

Should be fixed in https://github.com/Freika/dawarich/releases/tag/0.15.5, let me know if you're still having this problem

@Freika Freika closed this as completed Oct 19, 2024
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

No branches or pull requests

5 participants