VROOM-Project / vroom-docker

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

Not able to connect to Vroom using ors #41

Closed fischert00 closed 3 years ago

fischert00 commented 3 years ago

I'm trying to install Vroom and ORS on my windows 10 desktop to use with the openrouteservice r package. I install the 2 docker images as follows:

ORS

docker run -dt --name ors -p 8080:8080 -v $PWD/graphs:/ors-core/data/graphs -v $PWD/elevation_cache:/ors-core/data/elevation_cache -v $PWD/conf:/ors-conf -e "JAVA_OPTS=-Djava.awt.headless=true -server -XX:TargetSurvivorRatio=75 -XX:SurvivorRatio=64 -XX:MaxTenuringThreshold=3 -XX:+UseG1GC -XX:+ScavengeBeforeFullGC -XX:ParallelGCThreads=4 -Xms1g -Xmx2g" -e "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" openrouteservice/openrouteservice:latest

VROOM

docker run -dt --name vroom -p 3000:3000 -v $PWD/conf:/conf -e VROOM_ROUTER=ors vroomvrp/vroom-docker:v1.10.0

I can connect and see the health of ORS but not VROOM using the following:

ors http://localhost:8080/ors/health - {"status":"ready"}

vroom http://localhost:3000/health - it doesn't return anything.

if I do: http://localhost:3000/vroom/health - then I get the error - Cannot GET /vroom/health

If i try to access vroom via the R package openrouteservice I get a 404 error..

I also used curl to check and here is what I got:

ORS

curl http://host.docker.internal:8080

StatusCode : 200 StatusDescription : Content :

                <!DOCTYPE html>
                <html lang="en">
                    <head>
                        <meta charset="UTF-8" />
                        <title>Apache Tomcat/8.5.39</title>
                        <link href="favicon.ico" rel="icon" type="image/x-icon" />
                        <...

RawContent : HTTP/1.1 200 Transfer-Encoding: chunked Content-Type: text/html;charset=UTF-8 Date: Sat, 24 Jul 2021 18:29:03 GMT <!DOCTYPE html>

... Forms : {} Headers : {[Transfer-Encoding, chunked], [Content-Type, text/html;charset=UTF-8], [Date, Sat, 24 Jul 2021 18:29:03 GMT]} Images : {@{innerHTML=; innerText=; outerHTML=[tomcat logo]; outerText=; tagName=IMG; alt=[tomcat logo]; src=tomcat.png}} InputFields : {} Links : {@{innerHTML=Home; innerText=Home; outerHTML=Home; outerText=Home; tagName=A; href=https://tomcat.apache.org/}, @{innerHTML=Documentation; innerText=Documentation; outerHTML=Documentation; outerText=Documentation; tagName=A; href=/docs/}, @{innerHTML=Configuration; innerText=Configuration; outerHTML=Configuration; outerText=Configuration; tagName=A; href=/docs/config/}, @{innerHTML=Examples; innerText=Examples; outerHTML=Examples; outerText=Examples; tagName=A; href=/examples/}...} ParsedHtml : mshtml.HTMLDocumentClass RawContentLength : 11266 VROOM curl http://host.docker.internal:3000 curl : Cannot GET / At line:1 char:1 + curl http://host.docker.internal:3000 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand I also tried calling vroom with the following: curl --header "Content-Type:application/json" --data '{"vehicles":[{"id":0,"start":[42.316,-71.033],"end":[42.360,-71.093]}],"jobs":[{"id":0,"location":[42.358,-71.095]},{"id":1,"location":[42.339,-71.094]}],"options":{"g":true}}' http://localhost:3000 Invoke-WebRequest : A positional parameter cannot be found that accepts argument 'Content-Type:application/json'. At line:1 char:1 + curl --header "Content-Type:application/json" --data '{"vehicles":[{" ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand I'm sure I'm doing something wrong but I'm new to Docker and I've spent 10+ hours trying to figure this out so any help would be greatly appreciated. Thanks. Tom....
nilsnolde commented 3 years ago

So the vroom health endpoint won’t return any data per se, it’ll only „respond“ with a HTTP status code. Any other than 200 means vroom is not healthy.

I don’t know what shell you’re using but very much looks like powershell? My recommendation: make sure you can individually request each service with a dedicated program like postman. That normalizes the requests and you’re not depending on quirky PS ports of Unix commands such as curl.

As an aside: I didn’t look into ORS R package ever, are you sure it allows you to specify your own vroom endpoint? I’m pretty sure it only queries the live ORS instance. However you can probably copy paste the request building logic from the package into your own modules. I bet that’s why you’re seeing a 404 response from the R package.

fischert00 commented 3 years ago

Nilsnolde,

Thanks for your reply. Yes, I am using Powershell, I will take a look at postman. Also, ORS R package does allow you to call other endpoints, not just the public API via these commands:

options(openrouteservice.url = "http://localhost:8080/ors") options(openrouteservice.paths = list(directions = "v2/directions", isochrones = "v2/isochrones", matrix = "v2/matrix", geocode = "geocode", pois = "pois", elevation = "elevation", optimization = "optimization")) Here is the link to the ORS R page that tell you how to connect with other endpoints: https://github.com/GIScience/openrouteservice-r

I think the biggest issue is that when I try to check the health of Vroom using:

http://localhost:3000/health it doesn't return any status code, it doesn't return anything, the browser window is blank but when I do http://localhost:8080/ors/health I do get a return of {"status":"ready"}.

So, I feel like i didn't install it correctly or I'm using the wrong command to check the health or the port is wrong or not visible to Windows (I'm using the Edge Browser to issue the http://localhost:3000/health command.

When I do the following in PowershelL: curl http://host.docker.internal:3000/health

it returns:

StatusCode : 200 StatusDescription : OK Content : RawContent : HTTP/1.1 200 OK Access-Control-Allow-Origin: Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept Content-Security-Policy: default-src 'self';base-uri 'self';block-all-mix... Forms : {} Headers : {[Access-Control-Allow-Origin, ], [Access-Control-Allow-Headers, Origin, X-Requested-With, Content-Type, Accept], [Content-Security-Policy, default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self' https: data:;frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests], [X-DNS-Prefetch-Control, off]...} Images : {} InputFields : {} Links : {} ParsedHtml : mshtml.HTMLDocumentClass RawContentLength : 0

So, I do get a status code of 200 returned so internally to Docker it does appear to be there and healthy. If I have docker show me the port exposed using:

docker port vroom

if does return port 3000 as exposed:

3000/tcp -> 0.0.0.0:3000 3000/tcp -> :::3000

Is there something else I need to have between the 2 docker containers so they are able to communicate, it's like they can't see each other.

FYI, if I check the ports on ORS it returns this: docker port ors 8080/tcp -> 0.0.0.0:8080 8080/tcp -> :::8080

Not sure that helps but wanted to show that the ports appear to be visiable.

Thanks for the help, let me know what else I can provide to resolve this.

Tom...

jcoupey commented 3 years ago

curl http://host.docker.internal:3000 curl : Cannot GET /

If http://host.docker.internal:3000 is where vroom-express is exposed, this is expected for a GET request: you're supposed to use POST with the problem in the payload,

curl http://host.docker.internal:3000/health StatusCode : 200

Sounds encouraging. In order to test VROOM in isolation with the routing stack, you can use a standalone problem containing a matrix such as this example.

curl --header "Content-Type:application/json" --data @example_2.json http://host.docker.internal:3000
fischert00 commented 3 years ago

Thanks for the suggestion jcoupey.

Here is what happens when I do the standalone problem using Powershell (yes the xample_2.json file is in the current directory where this is being run from)::

curl --header "Content-Type:application/json" --data @example_2.json http://host.docker.internal:3000

At line:1 char:54

I'm obviously doing something wrong but am not experienced enough with Curl figure it out.

Thanks for your help. Tom...

fischert00 commented 3 years ago

Nevermind, I ran the curl command in the command window and got this back:

{"code":0,"summary": {"cost":5461,"unassigned":0,"service":0,"duration":5461,"waiting_time":0,"priority":0,"violations":[],"computing_times": {"loading":0,"solving":3}},"unassigned":[],"routes":[ {"vehicle":0,"cost":5461,"service":0,"duration":5461,"waiting_time":0,"priority":0,"steps":[ {"type":"start","service":0,"waiting_time":0,"arrival":0,"duration":0,"violations":[]}, {"type":"job","id":1414,"service":0,"waiting_time":0,"job":1414,"arrival":2104,"duration":2104,"violations":[]}, {"type":"job","id":1515,"service":0,"waiting_time":0,"job":1515,"arrival":4359,"duration":4359,"violations":[]}, {"type":"end","service":0,"waiting_time":0,"arrival":5461,"duration":5461,"violations":[]}],"violations":[]}]}

I assume it worked, don't know if this is the right answer or not but at least it's working. Now I need to figure out why ORS is not finding/seeing Vroom (the 404).

Thanks for the help, at least I know it appears to be working.

Tom...

nilsnolde commented 3 years ago

invoking curl on windows is not the same as invoking curl on linux. hence postman. you containers are all healthy I bet (just look at docker ps) and again, pretty sure the R package does not let you specify the endpoint: https://github.com/GIScience/openrouteservice-r/blob/9724247c8c70ecd9f5efdc1a5534b3833873fea1/R/optimization.R#L84-L90

even if you can change the base URL, the path will remain optimization. that is not a known path to ORS. the ORS live instance (api.ors.org) has an apache configured to map /optimization to vroom-express (I know that bcs I did it myself). unless you map that yourself inside the container with nginx/apache, you'll need to update the R package source or ask the maintainer to add that sort of flexibility to the package's public API.

nilsnolde commented 3 years ago

closing as not being an issue with this project.