VROOM-Project / vroom-docker

Docker image for vroom and vroom-express
BSD 2-Clause "Simplified" License
82 stars 55 forks source link

Post request vroom express python #10

Closed johnjinwoua closed 4 years ago

johnjinwoua commented 4 years ago

Hello,

I am trying to get solution from http request using vroom express but I have an error message.

I installed it locally using docker and I do the request to localhost:3000 as shown on the code below. Is it the right syntax ? Could someone help please ?

Thanks !

Capture d’écran 2020-05-24 à 09 03 35
nilsnolde commented 4 years ago

Hi,

a few things (more general when you put issues to FOSS projects):

To your problem: Don't see anything wrong on first glance. Can't say any more without seeing errors..

Do you want to use OSRM or ORS? Docker?

johnjinwoua commented 4 years ago

I am sorry for the screenshot.

Do you want to use OSRM or ORS? Docker? I use ORS with docker.

Don't see anything wrong on first glance. Can't say any more without seeing errors.. "code":1,"error":"Internal error"

jcoupey commented 4 years ago

A wild guess: maybe you should use call.json() to retrieve the response instead of call.text?

I have an error message.

Please copy-paste the error backtrace for more.

johnjinwoua commented 4 years ago

maybe you should use call.json() I've tried it out. same error message.

Please copy-paste the error backtrace for more. "POST / HTTP/1.1" 500 35 "-" "python-requests/2.22.0" in the access log

In the shell : 'code': 1, 'error': 'Internal error'

/bin/sh: vroom: command not found

nilsnolde commented 4 years ago

Ok, this will turn out to be a Docker issue, I'll transfer.

Can you pls share:

johnjinwoua commented 4 years ago

docker-compose.yml

version: "2.4"
services:
vroom:
network_mode: host
image: vroomvrp/vroom-docker:v1.6.0
container_name: vroom
volumes:
- ./vroom-conf/:/conf
environment:
- VROOM_ROUTER=ors  # router to use, osrm or ors
depends_on:
- ors-app
# Example for OpenRouteService
ors-app:
container_name: ors-app
ports:
- 8080:8080
build:
context: ../
args:
APP_CONFIG: ./docker/conf/app.config.sample
OSM_FILE: ./docker/data/luxembourg-latest.osm.pbf
volumes:
- ./graphs:/ors-core/data/graphs
- ./elevation_cache:/ors-core/data/elevation_cache
- ./logs/ors/:/var/log/ors/
- ./logs/tomcat/:/usr/local/tomcat/logs
- ./conf/app.config.sample:/ors-core/openrouteservice/target/classes/app.config
- ./data/luxembourg-latest.osm.pbf/ors-core/data/osm_file.pbf
environment:
- BUILD_GRAPHS=True  # Forces the container to rebuild the graphs, e.g. when PBF is changed in app.config
- JAVA_OPTS="-Djava.awt.headless=true -server -XX:TargetSurvivorRatio=75 -XX:SurvivorRatio=64 -XX:MaxTenuringThreshold=3 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:ParallelGCThreads=4 -Xms1g -Xmx2g"
- CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9001 -Dcom.sun.management.jmxremote.rmi.port=9001 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost"

vroom-conf/config.yml (in case you changed smth)

cliArgs:
geometry: false # retrieve geometry (-g)
threads: 4 # number of threads to use (-t)
explore: 5 # exploration level to use (0..5) (-x)
limit: '1mb' # max request size
logdir: '/..' # the path for the logs relative to ./src
maxlocations: 1000 # max number of jobs/shipments locations
maxvehicles: 200 # max number of vehicles
override: true # allow cli options override (-g, -t and -x)
path: '' # VROOM path (if not in $PATH)
port: 3000 # expressjs port
router: 'ors' # routing backend (osrm, libosrm or ors)
timeout: 300000 # milli-seconds
routingServers:
osrm:
car:
host: '0.0.0.0'
port: '5000'
bike:
host: '0.0.0.0'
port: '5000'
foot:
host: '0.0.0.0'
port: '5000'
ors:
driving-car:
host: '0.0.0.0'
port: '8080'
driving-hgv:
host: '0.0.0.0'
port: '8080'
cycling-regular:
host: '0.0.0.0'
port: '8080'
cycling-mountain:
host: '0.0.0.0'
port: '8080'
cycling-road:
host: '0.0.0.0'
port: '8080'
cycling-electric:
host: '0.0.0.0'
port: '8080'
foot-walking:
host: '0.0.0.0'
port: '8080'
foot-hiking:
host: '0.0.0.0'
port: '8080'

command you used to start a container

docker-compose up --build (and -d further)

output of docker logs vroom

::1 - - [25/May/2020:06:25:55 +0000] "POST / HTTP/1.1" 500 35 "-" "curl/7.64.1"
::1 - - [25/May/2020:06:27:46 +0000] "POST / HTTP/1.1" 500 35 "-" "curl/7.64.1"
nilsnolde commented 4 years ago

Have a look here for correct Markdown syntax: https://guides.github.com/pdfs/markdown-cheatsheet-online.pdf. Proper formatting is seriously important, this time I fixed it for you.

One thing to note is that ORS is not on its latest here wrt docker-compose setup since this landed: https://github.com/GIScience/openrouteservice/pull/717. Will update vroom-docker now, though that won't solve your particular problem.

Hm, that's weird.. Looks ok from what I can see.

A few more things to try:

johnjinwoua commented 4 years ago

Sorry for the syntaxes... I am not used to. These are the outputs of the different questions :

Can you please show the full output of docker ps?

7f12a1389ce3        vroomvrp/vroom-docker:v1.6.0               "/bin/bash /docker-e…"   44 hours ago        Up 29 hours (healthy)                            vroom
85b20e5aa4d0        openrouteservice/openrouteservice:v6.1.0   "/bin/bash /docker-e…"   47 hours ago        Up 46 hours             0.0.0.0:8080->8080/tcp   ors-app

There's a /health endpoint, does curl --fail -s http://localhost:3000/health give a 200 response?

It gives me a blank (white) page with no message at all in Safari navigator. And in the shell, I have no output message when I execute the curl

do cd /vroom/bin && ./vroom

No such file or directory

If not, what's the output of echo $PATH?

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

nilsnolde commented 4 years ago

Not sure where it's going wrong, but what you're describing it's actually pretty much impossible;)

You're reporting that you get a /bin/sh: vroom: command not found when you're doing a request to vroom. But the docker container is healthy as shown in your docker ps. That means the vroom executable is indeed in the PATH of the vroom container and the error message you're getting can't come from that container. So I think you have a basic mistake somewhere that we don't see.

I just did the whole thing again from scratch and I can't reproduce your problem. Please try my config below. If you keep everything default (do a new pull though as I changed the docker-compose.yml) and you use the default ORS file from here, then this setup:

version: "2.4"
services:
  vroom:
    network_mode: host
    image: vroomvrp/vroom-docker:v1.6.0
    container_name: vroom
    volumes:
      - ./vroom-conf/:/conf
    environment:
      - VROOM_ROUTER=ors  # router to use, osrm or ors
    depends_on:
      - ors
  # Example for OpenRouteService
  ors:
    container_name: ors
    ports:
      - 8080:8080
    image: openrouteservice/openrouteservice:latest
    volumes:
      - ./graphs:/ors-core/data/graphs
      - ./elevation_cache:/ors-core/data/elevation_cache
      - ./logs/ors:/var/log/ors
      - ./logs/tomcat:/usr/local/tomcat/logs
      - ./conf:/ors-conf
      - ./data/heidelberg.osm.gz:/ors-core/data/osm_file.pbf
    environment:
      - BUILD_GRAPHS=True  # Forces the container to rebuild the graphs, e.g. when PBF is changed in app.config
      - "JAVA_OPTS=-Djava.awt.headless=true -server -XX:TargetSurvivorRatio=75 -XX:SurvivorRatio=64 -XX:MaxTenuringThreshold=3 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:ParallelGCThreads=4 -Xms1g -Xmx2g"
      - "CATALINA_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9001 -Dcom.sun.management.jmxremote.rmi.port=9001 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost"

you're able to complete this request successfully:

curl --location --request POST 'http://localhost:3000' \
--header 'Content-Type: application/json' \
--data-raw '
{
  "vehicles": [
    {
      "id": 1,
      "profile": "driving-car",
      "start": [
       8.692675, 49.415887
      ],
      "end": [
        8.692675, 49.415887
      ],
      "capacity": [
        4
      ],
      "skills": [
        1,
        14
      ],
      "time_window": [
        28800,
        43200
      ],
      "breaks": [
        {
          "id": 1,
          "service": 300,
          "time_windows": [
            [
              32400,
              34200
            ]
          ]
        }
      ]
    },
    {
      "id": 2,
      "profile": "driving-car",
      "start": [
        8.675165, 49.41639
      ],
      "end": [
        8.675165, 49.41639
      ],
      "capacity": [
        4
      ],
      "skills": [
        2,
        14
      ],
      "time_window": [
        28800,
        43200
      ],
      "breaks": [
        {
          "id": 2,
          "service": 300,
          "time_windows": [
            [
              34200,
              36000
            ]
          ]
        }
      ]
    }
  ],
  "jobs": [
    {
      "id": 1,
      "service": 300,
      "delivery": [
        1
      ],
      "location": [
        8.684864, 49.420745
      ],
      "skills": [
        1
      ],
      "time_windows": [
        [
          32400,
          36000
        ]
      ]
    },
    {
      "id": 2,
      "service": 300,
      "pickup": [
        1
      ],
      "location": [
        8.682976, 49.421917
      ],
      "skills": [
        1
      ]
    },
    {
      "id": 5,
      "service": 300,
      "delivery": [
        1
      ],
      "location": [
       8.68907, 49.417842
      ],
      "skills": [
        14
      ]
    },
    {
      "id": 6,
      "service": 300,
      "delivery": [
        1
      ],
      "location": [
       8.673363, 49.411643
      ],
      "skills": [
        14
      ]
    }
  ]
}'
johnjinwoua commented 4 years ago

Thanks for all. I find my mistake. I was running the curl request in the terminal. Not in the container.

I launch a shell in the container by doing :

docker exec -it <ID_of_the_container> /bin/sh

And only after launching a shell within the container, I tried the curl request and it works ! :)

Thanks again for your precious time.

Closing.