GIScience / openpoiservice

:round_pushpin: Openpoiservice is a flask application which hosts a highly customizable points of interest database derived from OpenStreetMap data.
https://openrouteservice.org
Apache License 2.0
171 stars 22 forks source link

All time Internal Server Error #73

Closed kshnkvn closed 4 years ago

kshnkvn commented 4 years ago

I'll trying to make simple request:

curl -X POST \
  http://127.0.0.1:5000/pois \
  -H 'Content-Type: application/json' \
  -d '{
  "request": "pois",
  "geometry": {
    "bbox": [
      [32.70149630013472, -96.72892645140573],
      [32.70137085098112, -96.72854256023189],
      [32.710300884253556, -96.72420399392107]
    ] 
  }
}'

But all time i'll got status 500 and:

<html>
  <head>
    <title>Internal Server Error</title>
  </head>
  <body>
    <h1><p>Internal Server Error</p></h1>

  </body>
</html>

Is it wrong bbox, or error with openpoiservice? How i can check it?

zephylac commented 4 years ago

bbox are called Bounding Box which mean they represent a square. OpenPoiService is using this format [[minLong, minLat], [maxLong,minLong]]

If you follow examples in the README, you'll find this example:

"bbox": [
      [8.8034, 53.0756],
      [8.7834, 53.0456]
    ]

So in your case, your bbox is invalid.

kshnkvn commented 4 years ago

@zephylac ok, i fixed request:

curl -X POST \
  http://13.84.170.186:8080/pois \
  -H 'Content-Type: application/json' \
  -d '{
  "request": "pois",
  "geometry": {
    "bbox": [
      [-87.922176, 41.995132],
      [-87.805886, 42.066193]
    ] 
  }
}'

But this are still not works. Same error

zephylac commented 4 years ago

Have you imported the correct osm file ?

kshnkvn commented 4 years ago

@zephylac probably ... There were no errors during import, so I believe that yes, it is correct.

zephylac commented 4 years ago

OSM file usually contains a small portion of geographical area. It means you can only have query which are inside this geographical area. Also are you using the docker build ?

kshnkvn commented 4 years ago

Also are you using the docker build ?

@zephylac yes, docker.

It means you can only have query which are inside this geographical area.

Can you, please, explain this?

zephylac commented 4 years ago

You can running instances with docker ps. You should be able to see two containers named openpoiservice_psql_postgis_db_1 and openpoiservice_gunicorn_flask_1. Then you can check the logs of a container by using docker logs <container name>.

Try docker logs openpoiservice_gunicorn_flask_1 and tell me if you see something like this:

  File "/deploy/app/openpoiservice/server/api/views.py", line 123, in places
    if all_args['geometry']['geojson']['type'] == 'MultiPolygon':
KeyError: 'geojson'
kshnkvn commented 4 years ago

@zephylac no, nothing like it. But there are lot of errors like this:

[2020-02-20 07:16:58 +0000] [10] [ERROR] Error handling request /
Traceback (most recent call last):
  File "/ops_venv/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/ops_venv/lib/python3.6/site-packages/flask/app.py", line 1590, in dispatch_request
    self.raise_routing_exception(req)
  File "/ops_venv/lib/python3.6/site-packages/flask/app.py", line 1573, in raise_routing_exception
    raise request.routing_exception
  File "/ops_venv/lib/python3.6/site-packages/flask/ctx.py", line 294, in match_request
    self.url_adapter.match(return_rule=True)
  File "/ops_venv/lib/python3.6/site-packages/werkzeug/routing.py", line 1945, in match
    raise NotFound()
werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/ops_venv/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/ops_venv/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/ops_venv/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/ops_venv/lib/python3.6/site-packages/flask/app.py", line 1512, in handle_user_exception
    return self.handle_http_exception(e)
  File "/ops_venv/lib/python3.6/site-packages/flask/app.py", line 1471, in handle_http_exception
    return handler(e)
  File "/deploy/app/openpoiservice/server/__init__.py", line 82, in page_not_found
    return jsonify({"error_message": 404})
  File "/ops_venv/lib/python3.6/site-packages/flask/json.py", line 251, in jsonify
    if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] and not request.is_xhr:
  File "/ops_venv/lib/python3.6/site-packages/werkzeug/local.py", line 347, in __getattr__
    return getattr(self._get_current_object(), name)
AttributeError: 'Request' object has no attribute 'is_xhr'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/ops_venv/lib/python3.6/site-packages/gunicorn/workers/async.py", line 56, in handle
    self.handle_request(listener_name, req, client, addr)
  File "/ops_venv/lib/python3.6/site-packages/gunicorn/workers/ggevent.py", line 152, in handle_request
    super(GeventWorker, self).handle_request(*args)
  File "/ops_venv/lib/python3.6/site-packages/gunicorn/workers/async.py", line 107, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/ops_venv/lib/python3.6/site-packages/flask/app.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "/ops_venv/lib/python3.6/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/ops_venv/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/ops_venv/lib/python3.6/site-packages/flask/app.py", line 1547, in handle_exception
    return self.finalize_request(handler(e), from_error_handler=True)
  File "/deploy/app/openpoiservice/server/__init__.py", line 86, in server_error_page
    return jsonify({"error_message": 500})
  File "/ops_venv/lib/python3.6/site-packages/flask/json.py", line 251, in jsonify
    if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] and not request.is_xhr:
  File "/ops_venv/lib/python3.6/site-packages/werkzeug/local.py", line 347, in __getattr__
    return getattr(self._get_current_object(), name)
AttributeError: 'Request' object has no attribute 'is_xhr'
zephylac commented 4 years ago

Can you try your request on a local scope ?

kshnkvn commented 4 years ago

@zephylac need to install it on local machine. I don’t think it will be fast, maybe only tomorrow. By the way, when I tested locally, I remember I had the same errors in the logs.

zephylac commented 4 years ago

Can you share your docker-compose.yml if you are using docker-compose

kshnkvn commented 4 years ago

@zephylac here is it: pastebin

nilsnolde commented 4 years ago

Well, you do

ports:
   - "8080:8080"

which opens port 8080 and you request port 5000 in your example, but even worse you map to the wrong port within the Docker container. If you want port 8080 to be open on your server instead of 5000, then do

ports:
   - "8080:5000"
zephylac commented 4 years ago

In your ports 8080:8080. You don't want to change the right hand side part.

:. Flask is running on port 5000. You can only change the left part meaning the valid configuration is `8080:5000`
nilsnolde commented 4 years ago

hihi, sorry @zephylac

kshnkvn commented 4 years ago

@zephylac wow, thank you. So i need to rebuild all?

nilsnolde commented 4 years ago

No, you don't need to. Just start a new container.

nilsnolde commented 4 years ago

Sorry, do docker-compose down, then docker-compose up -d again, that should be enough

kshnkvn commented 4 years ago

@zephylac wait, no, i changed bind port in gunicorn to this:

bind = "0.0.0.0:8080"

And docker ps:

CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS              PORTS                    NAMES
3a3b3958b001        openpoiservice_gunicorn_flask   "/ops_venv/bin/gunic…"   7 days ago          Up 7 days           0.0.0.0:8080->8080/tcp   openpoiservice_gunicorn_flask_1

Sorry i just forgot this.

kshnkvn commented 4 years ago

@zephylac @nilsnolde do i need to open new issue?

zephylac commented 4 years ago

Then try this command : curl -X POST http://localhost:6000/pois -H 'content-type: application/json' -d '{"request": "list"}'

kshnkvn commented 4 years ago

@zephylac

ivan@poi-api:~$ curl -X POST http://127.0.0.1:8080/pois -H 'content-type: application/json' -d '{"request": "list"}'
{"accomodation": {"id": 100, "children": {"tourism": {"alpine_hut": 101, "apartment": 102, "camp_site": 103, "caravan_site": 104, "chalet": 105, "guest_house": 106, "hostel": 107, "hotel": 108, "motel": 109, "wilderness_hut": 110}}}, "animals": {"id": 120, "children": {"amenity": {"animal_boarding": 121, "animal_shelter": 122, "veterinary": 123}, "shop": {"pet": 124}}}, "arts_and_culture": {"id": 130, "children": {"amenity": {"arts_centre": 131, "library": 133, "place_of_worship": 135, "studio": 136}, "tourism": {"gallery": 132, "museum": 134}}}, "education": {"id": 150, "children": {"amenity": {"college": 151, "driving_school": 152, "kindergarten": 153, "language_school": 154, "music_school": 155, "school": 156, "university": 157}}}, "facilities": {"id": 160, "children": {"amenity": {"compressed_air": 161, "bench": 162, "emergency_phone": 163, "clock": 164, "drinking_water": 166, "hunting_stand": 168, "internet_cafe": 169, "kneipp_water_cure": 170, "post_box": 171, "recycling": 172, "sanitary_dump_station": 174, "shelter": 175, "shower": 176, "table": 177, "telephone": 178, "toilets": 179, "waste_basket": 180, "waste_disposal": 181, "water_point": 182}, "emergency": {"access_point": 205, "defibrillator": 165, "fire_hydrant": 167}}}, "financial": {"id": 190, "children": {"amenity": {"atm": 191, "bank": 192, "bureau_de_change": 193}}}, "healthcare": {"id": 200, "children": {"amenity": {"baby_hatch": 201, "clinic": 202, "dentist": 203, "doctors": 204, "hospital": 206, "nursing_home": 207, "pharmacy": 208, "retirement_home": 209, "social_facility": 210}, "healthcare": {"blood_donation": 211}}}, "historic": {"id": 220, "children": {"historic": {"aircraft": 221, "aqueduct": 222, "archaeological_site": 223, "castle": 224, "cannon": 225, "city_gate": 226, "citywalls": 227, "battlefield": 228, "boundary_stone": 229, "building": 230, "farm": 231, "fort": 232, "gallows": 233, "highwater_mark": 234, "locomotive": 235, "manor": 236, "memorial": 237, "milestone": 238, "monastery": 239, "monument": 240, "optical_telegraph": 241, "pillory": 242, "ruins": 243, "rune_stone": 244, "ship": 245, "tomb": 246, "wayside_cross": 247, "wayside_shrine": 248, "wreck": 249}}}, "leisure_and_entertainment": {"id": 260, "children": {"leisure": {"adult_gaming_centre": 261, "amusement_arcade": 262, "beach_resort": 263, "bandstand": 264, "bird_hide": 265, "common": 266, "dance": 267, "dog_park": 268, "firepit": 269, "fishing": 270, "fitness_centre": 271, "garden": 272, "golf_course": 273, "hackerspace": 274, "horse_riding": 275, "ice_rink": 276, "marina": 277, "miniature_golf": 278, "nature_reserve": 279, "park": 280, "picnic_table": 281, "pitch": 282, "playground": 283, "sauna": 286, "slipway": 287, "sports_centre": 288, "stadium": 289, "summer_camp": 290, "swimming_area": 291, "swimming_pool": 292, "track": 293, "turkish_bath": 294, "water_park": 295, "wildlife_hide": 296}, "highway": {"raceway": 284}, "amenity": {"brothel": 297, "casino": 298, "cinema": 299, "dive_centre": 300, "dojo": 301, "gambling": 302, "nightclub": 303, "planetarium": 304, "public_bath": 285, "social_centre": 305, "spa": 306, "stripclub": 307}, "tourism": {"aquarium": 308, "theme_park": 309, "zoo": 310}}}, "natural": {"id": 330, "children": {"natural": {"cave_entrance": 331, "beach": 332, "geyser": 333, "peak": 335, "rock": 336, "saddle": 337, "spring": 338, "volcano": 339, "water": 340}}}, "public_places": {"id": 360, "children": {"amenity": {"embassy": 361, "crematorium": 362, "community_centre": 363, "courthouse": 364, "coworking_space": 365, "crypt": 366, "fire_station": 367, "grave_yard": 368, "police": 369, "post_office": 370, "prison": 371, "ranger_station": 372, "rescue_station": 373, "townhall": 374}}}, "service": {"id": 390, "children": {"shop": {"beauty": 391, "estate_agent": 392, "dry_cleaning": 393, "glaziery": 394, "hairdresser": 395, "laundry": 396, "massage": 397, "tailor": 399, "tattoo": 400}, "amenity": {"photo_booth": 398}}}, "shops": {"id": 420, "children": {"shop": {"agrarian": 421, "alcohol": 422, "antiques": 423, "art": 424, "bag": 425, "bakery": 426, "bed": 427, "beverages": 428, "bicycle": 429, "books": 430, "boutique": 431, "brewing_supplies": 432, "business_machines": 433, "butcher": 434, "cafe": 435, "camera": 436, "candles": 437, "car": 438, "car_parts": 439, "carpet": 440, "curtain": 441, "cheese": 442, "chemist": 443, "chocolate": 444, "clothes": 447, "coffee": 448, "computer": 449, "confectionery": 450, "convenience": 451, "copyshop": 452, "cosmetics": 453, "dairy": 454, "deli": 455, "department_store": 456, "doityourself": 457, "electrical": 458, "electronics": 459, "erotic": 460, "e-cigarette": 461, "farm": 462, "fashion": 463, "fishing": 464, "florist": 465, "funeral_directors": 466, "furniture": 467, "games": 468, "garden_centre": 469, "garden_furniture": 470, "gas": 471, "general": 472, "gift": 473, "greengrocer": 474, "grocery": 475, "interior_decoration": 476, "hairdresser_supply": 477, "hardware": 478, "hearing_aids": 479, "herbalist": 480, "hifi": 481, "houseware": 482, "hunting": 483, "insurance": 484, "jewelry": 485, "leather": 486, "locksmith": 487, "kiosk": 488, "kitchen": 489, "lamps": 490, "lottery": 491, "mall": 492, "medical_supply": 494, "mobile_phone": 495, "model": 496, "motorcycle": 497, "music": 498, "musical_instrument": 499, "nutrition_supplements": 500, "newsagent": 501, "optician": 502, "organic": 503, "outdoor": 504, "paint": 505, "pastry": 506, "perfumery": 507, "photo": 508, "pyrotechnics": 509, "radiotechnics": 510, "seafood": 511, "second_hand": 512, "security": 513, "shoes": 514, "spices": 515, "sports": 516, "stationery": 517, "supermarket": 518, "swimming_pool": 519, "tea": 520, "ticket": 521, "tiles": 522, "tobacco": 523, "toys": 524, "trophy": 525, "tyres": 526, "variety_store": 527, "video": 529, "video_games": 530, "watches": 531, "weapons": 532, "wine": 533}, "amenity": {"marketplace": 493, "vending_machine": 528}}}, "sustenance": {"id": 560, "children": {"amenity": {"bar": 561, "bbq": 562, "biergarten": 563, "cafe": 564, "drinking_water": 565, "fast_food": 566, "food_court": 567, "ice_cream": 568, "pub": 569, "restaurant": 570}}}, "transport": {"id": 580, "children": {"aeroway": {"aerodrome": 581, "helipad": 598, "heliport": 599}, "amenity": {"bicycle_parking": 583, "bicycle_rental": 584, "bicycle_repair_station": 585, "boat_sharing": 586, "bus_station": 587, "bus_stop": 588, "car_rental": 589, "car_repair": 590, "car_sharing": 591, "car_wash": 592, "charging_station": 593, "ev_charging": 594, "ferry_terminal": 595, "fuel": 596, "motorcycle_parking": 600, "parking": 601, "parking_entrance": 602, "parking_space": 603, "taxi": 606}, "railway": {"halt": 597, "station": 604, "tram_stop": 605}, "public_transport": {"platform": 607, "stop_position": 608, "stop_area": 609, "station": 610}}}, "tourism": {"id": 620, "children": {"tourism": {"artwork": 621, "attraction": 622, "information": 624, "picnic_site": 625, "viewpoint": 627}, "amenity": {"fountain": 623}, "shop": {"travel_agency": 626}}}}
zephylac commented 4 years ago

Can ytou run those 2 commands docker exec -it openpoiservice_gunicorn_flask_1 /ops_venv/bin/activate;pip show Flask docker exec -it openpoiservice_gunicorn_flask_1 /ops_venv/bin/activate;pip show Werkzeug

kshnkvn commented 4 years ago

@zephylac

OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec: \"/ops_venv/bin/activate\": permission denied": unknown

Command 'pip' not found, but can be installed with:

sudo apt install python-pip
zephylac commented 4 years ago

And this ? docker exec -it openpoiservice_gunicorn_flask_1 /ops_venv/bin/pip3 show Flask Werkzeug

kshnkvn commented 4 years ago

@zephylac

Name: Flask
Version: 0.12.2
Summary: A microframework based on Werkzeug, Jinja2 and good intentions
Home-page: http://github.com/pallets/flask/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD
Location: /ops_venv/lib/python3.6/site-packages
Requires: Werkzeug, itsdangerous, click, Jinja2
Required-by: Flask-Testing, Flask-SQLAlchemy, Flask-DebugToolbar, Flask-Cors, flasgger
---
Name: Werkzeug
Version: 1.0.0
Summary: The comprehensive WSGI web application library.
Home-page: https://palletsprojects.com/p/werkzeug/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD-3-Clause
Location: /ops_venv/lib/python3.6/site-packages
Requires:
Required-by: Flask, Flask-DebugToolbar
zephylac commented 4 years ago

Yeah so that's coming from Werkzeug. It has received a major update. Before that we were on 0.15.5.

zephylac commented 4 years ago

@TimMcCauley @nilsnolde What do you guys wanna do ? I guess we should update to support the new version of Werkzeug ? It seems that only switching to Flask 1.0.0 fix this issue.

kshnkvn commented 4 years ago

@zephylac is it possible to add a correct version of Werkzeug into requirements.txt? I mean if I add Werkzeug==0.15.5 it will not be replaced by a current version from the flask?

zephylac commented 4 years ago

@kshnkvn it will work yes. But if they release a new version, they must have fixed issues. I mean It's better practice to support this critical package rather than freezing it.

kshnkvn commented 4 years ago

@zephylac yes, with 0.15.5 all works. Thank you.

nilsnolde commented 4 years ago

Yeah, I guess we should update it at some point. For now, we can pin the Werkzeug version I'd say. I'm VERY surprised Flask has no proper version pinning and start installing incompatible packages, which is exactly what libraries should avoid. And yep: current Flask master installs "Werkzeug>=0.15", so that's where our problem's coming from. But that also tells us that there is no critical update and 0.15.5 should be totally OK to use. I'll provide a PR to fix it.

Is that ok with you @zephylac ?

nilsnolde commented 4 years ago

Now, the weird thing is: I recently built a new Docker container for ops with the "old" requirements.txt and just checked: also has Werkzeug 1.0.0 and I can request all resources..