SoftInstigate / restheart-blog-example

Example blog application built with RESTHeart and AngularJS
GNU Affero General Public License v3.0
9 stars 6 forks source link

Have got "405 Method Not Allowed" #4

Closed greezlyk closed 8 years ago

greezlyk commented 8 years ago

Hello The SoftInstigate Team!

Tried to use this example , instilled docker image and run locally. When I try to save new post I get "405 Method Not Allowed"

curl 'http://127.0.0.1:8080/data/blog/posts/' -H 'No-Auth-Challenge: true' -H 'Origin: http://localhost:63342' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: nb,no;q=0.8,nn;q=0.6,en-US;q=0.4,en;q=0.2,ru;q=0.2' -H 'Authorization: Basic YWRtaW46MzZhODU4M2UtOWM5Zi00ZWI0LTgxOWQtYzhiNTM1NGEyYTgz' -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept: application/hal+json' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36' -H 'Cache-Control: max-age=0' -H 'Referer: http://localhost:63342/restheart-blog-example/app/index.html' -H 'Connection: keep-alive' -H 'If-Match: 56cb70ccc9e77c00070579d3' --data-binary '{"_links":{"self":{"href":"/data/blog/posts/posts"},"curies":[]},"_id":"posts","title":"My title","author":"Alex greezlyk","content":"<p>The body of the message</p>","summary":"My summary","_etag":{"$oid":"56cb70ccc9e77c00070579d3"}}' 
--compressed

screenshot from 2016-02-22 21 48 26

ujibang commented 8 years ago

Hi @greezlyk

can you please paste the logs of RESTHeart?

ujibang commented 8 years ago

also make sure you are using the configuration files restheart.yml and security.yml shipped with this repo and not the default one that comes with the docker image

for this you can use the data volume feature of docker https://docs.docker.com/engine/userguide/containers/dockervolumes/

copy the two files in etc dir

$ docker run -d -p 80:8080 -v etc:/opt/restheart/etc --name restheart --link mongodb:mongodb softinstigate/restheart
greezlyk commented 8 years ago

I have mounted both restheart.yml security.yml root@09e12507d2a1:/opt/restheart/etc# ls restheart.yml restheartd.conf security.yml

Here the log file from Restheart docker image:

20:28:15.001 [main] INFO org.restheart.Bootstrapper - Starting RESTHeart 20:28:15.004 [main] INFO org.restheart.Bootstrapper - version 1.1.3 20:28:15.006 [main] INFO org.restheart.Bootstrapper - Logging to console with level INFO 20:28:15.167 [main] INFO org.restheart.Bootstrapper - MongoDB connection pool initialized 20:28:15.167 [main] INFO org.restheart.Bootstrapper - MongoDB version 3.0.8 20:28:15.279 [main] INFO org.restheart.Bootstrapper - Token based authentication enabled with token TTL 15 minutes 20:28:15.425 [main] INFO org.restheart.Bootstrapper - HTTPS listener bound at 0.0.0.0:4443 20:28:15.425 [main] INFO org.restheart.Bootstrapper - HTTP listener bound at 0.0.0.0:8080 20:28:15.426 [main] INFO org.restheart.Bootstrapper - Local cache for db and collection properties enabled 20:28:15.449 [main] INFO org.restheart.Bootstrapper - URL / bound to MongoDB resource * 20:28:15.509 [main] INFO org.restheart.Bootstrapper - Embedded static resources browser extracted in /tmp/restheart-7401721267377391771 20:28:15.514 [main] INFO org.restheart.Bootstrapper - URL /browser bound to static resources browser. access manager: false 20:28:15.515 [main] INFO org.restheart.Bootstrapper - URL /_logic/ping bound to application logic handler org.restheart.handlers.applicationlogic.PingHandler. access manager: false 20:28:15.516 [main] INFO org.restheart.Bootstrapper - URL /_logic/roles bound to application logic handler org.restheart.handlers.applicationlogic.GetRoleHandler. access manager: false 20:28:15.636 [main] INFO org.restheart.Bootstrapper - Pid file /var/run/restheart--1441246088.pid 20:28:15.636 [main] INFO org.restheart.Bootstrapper - RESTHeart started

greezlyk commented 8 years ago

log with ALL mode:

21:44:08.514 [main] INFO org.restheart.Bootstrapper - Starting RESTHeart 21:44:08.516 [main] INFO org.restheart.Bootstrapper - version 1.1.3 21:44:08.519 [main] WARN org.restheart.Bootstrapper - Found pid file! If this instance is already running, startup will fail with a BindException 21:44:08.519 [main] INFO org.restheart.Bootstrapper - Logging to console with level ALL 21:44:08.523 [main] DEBUG org.restheart.Bootstrapper - Initializing MongoDB connection pool to [mongodb] with options MongoClientOptions{description='null', readPreference=primary, writeConcern=WriteConcern{w=null, wTimeout=null ms, fsync=null, journal=null, readConcern=com.mongodb.ReadConcern@0, codecRegistry=org.bson.codecs.configuration.ProvidersCodecRegistry@455c1c1d, commandListeners=[], minConnectionsPerHost=0, maxConnectionsPerHost=100, threadsAllowedToBlockForConnectionMultiplier=5, serverSelectionTimeout=30000, maxWaitTime=120000, maxConnectionIdleTime=0, maxConnectionLifeTime=0, connectTimeout=10000, socketTimeout=0, socketKeepAlive=false, sslEnabled=false, sslInvalidHostNamesAllowed=false, alwaysUseMBeans=false, heartbeatFrequency=10000, minHeartbeatFrequency=500, heartbeatConnectTimeout=20000, heartbeatSocketTimeout=20000, localThreshold=15, requiredReplicaSetName='null', dbDecoderFactory=com.mongodb.DefaultDBDecoder$1@73d4cc9e, dbEncoderFactory=com.mongodb.DefaultDBEncoder$1@80169cf, socketFactory=javax.net.DefaultSocketFactory@5427c60c, cursorFinalizerEnabled=true, connectionPoolSettings=ConnectionPoolSettings{maxSize=100, minSize=0, maxWaitQueueSize=500, maxWaitTimeMS=120000, maxConnectionLifeTimeMS=0, maxConnectionIdleTimeMS=0, maintenanceInitialDelayMS=0, maintenanceFrequencyMS=60000}, socketSettings=SocketSettings{connectTimeoutMS=10000, readTimeoutMS=0, keepAlive=false, receiveBufferSize=0, sendBufferSize=0}, serverSettings=ServerSettings{heartbeatFrequencyMS=10000, minHeartbeatFrequencyMS=500}, heartbeatSocketSettings=SocketSettings{connectTimeoutMS=20000, readTimeoutMS=20000, keepAlive=false, receiveBufferSize=0, sendBufferSize=0}} 21:44:08.697 [main] INFO org.restheart.Bootstrapper - MongoDB connection pool initialized 21:44:08.697 [main] INFO org.restheart.Bootstrapper - MongoDB version 3.0.8 21:44:08.811 [main] INFO org.restheart.Bootstrapper - Token based authentication enabled with token TTL 15 minutes 21:44:08.962 [main] INFO org.restheart.Bootstrapper - HTTPS listener bound at 0.0.0.0:4443 21:44:08.963 [main] INFO org.restheart.Bootstrapper - HTTP listener bound at 0.0.0.0:8080 21:44:08.964 [main] INFO org.restheart.Bootstrapper - Local cache for db and collection properties enabled 21:44:08.972 [main] DEBUG o.r.handlers.RequestDispacherHandler - Initialize default HTTP handlers: 21:44:08.975 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( ROOT, GET, org.restheart.handlers.root.GetRootHandler ) 21:44:08.976 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( DB, GET, org.restheart.handlers.database.GetDBHandler ) 21:44:08.977 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( DB, PUT, org.restheart.handlers.database.PutDBHandler ) 21:44:08.977 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( DB, DELETE, org.restheart.handlers.database.DeleteDBHandler ) 21:44:08.977 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( DB, PATCH, org.restheart.handlers.database.PatchDBHandler ) 21:44:08.977 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( COLLECTION, GET, org.restheart.handlers.collection.GetCollectionHandler ) 21:44:08.980 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( COLLECTION, POST, org.restheart.handlers.collection.PostCollectionHandler ) 21:44:08.980 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( COLLECTION, PUT, org.restheart.handlers.collection.PutCollectionHandler ) 21:44:08.980 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( COLLECTION, DELETE, org.restheart.handlers.collection.DeleteCollectionHandler ) 21:44:08.980 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( COLLECTION, PATCH, org.restheart.handlers.collection.PatchCollectionHandler ) 21:44:08.980 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( DOCUMENT, GET, org.restheart.handlers.document.GetDocumentHandler ) 21:44:08.981 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( DOCUMENT, PUT, org.restheart.handlers.document.PutDocumentHandler ) 21:44:08.981 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( DOCUMENT, DELETE, org.restheart.handlers.document.DeleteDocumentHandler ) 21:44:08.981 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( DOCUMENT, PATCH, org.restheart.handlers.document.PatchDocumentHandler ) 21:44:08.981 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( COLLECTION_INDEXES, GET, org.restheart.handlers.indexes.GetIndexesHandler ) 21:44:08.981 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( INDEX, PUT, org.restheart.handlers.indexes.PutIndexHandler ) 21:44:08.981 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( INDEX, DELETE, org.restheart.handlers.indexes.DeleteIndexHandler ) 21:44:08.981 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( FILES_BUCKET, GET, org.restheart.handlers.collection.GetCollectionHandler ) 21:44:08.982 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( FILES_BUCKET, POST, org.restheart.handlers.files.PostBucketHandler ) 21:44:08.982 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( FILES_BUCKET, PUT, org.restheart.handlers.files.PutBucketHandler ) 21:44:08.984 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( FILES_BUCKET, DELETE, org.restheart.handlers.files.DeleteBucketHandler ) 21:44:08.984 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( FILE, GET, org.restheart.handlers.files.GetFileHandler ) 21:44:08.984 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( FILE_BINARY, GET, org.restheart.handlers.files.GetFileBinaryHandler ) 21:44:08.985 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( FILE, PUT, org.restheart.handlers.files.PutFileHandler ) 21:44:08.985 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( FILE, DELETE, org.restheart.handlers.files.DeleteFileHandler ) 21:44:08.986 [main] DEBUG o.r.handlers.RequestDispacherHandler - putPipedHttpHandler( AGGREGATION, GET, org.restheart.handlers.aggregation.GetAggregationHandler ) 21:44:08.999 [main] INFO org.restheart.Bootstrapper - URL / bound to MongoDB resource * 21:44:09.087 [main] INFO org.restheart.Bootstrapper - Embedded static resources browser extracted in /tmp/restheart-6936444083912439810 21:44:09.091 [main] INFO org.restheart.Bootstrapper - URL /browser bound to static resources browser. access manager: false 21:44:09.093 [main] INFO org.restheart.Bootstrapper - URL /_logic/ping bound to application logic handler org.restheart.handlers.applicationlogic.PingHandler. access manager: false 21:44:09.093 [main] INFO org.restheart.Bootstrapper - URL /_logic/roles bound to application logic handler org.restheart.handlers.applicationlogic.GetRoleHandler. access manager: false 21:44:09.211 [main] INFO org.restheart.Bootstrapper - Pid file /var/run/restheart--1441246088.pid 21:44:09.212 [main] INFO org.restheart.Bootstrapper - RESTHeart started 21:45:39.494 [XNIO-1 task-2] DEBUG o.r.handlers.RequestDispacherHandler - Call to getPipedHttpHandler(DOCUMENT, POST) can't find any PipedHttpHandler

ujibang commented 8 years ago

in log you have

20:28:15.449 [main] INFO org.restheart.Bootstrapper - URL / bound to MongoDB resource *

it should be URL /data bound to MongoDB resource *

because in the shipped restheart.yml

# Use mongo-mounts to bind URls to mongodb resources using the out-of-the-box URL rewrite feature.
mongo-mounts:
    - what: "*"
      where: /data

double check your docker container. you can check if the configuration file is there with:

$ docker exec -it <name-of-your-container> /bin/bash

bash-4.3# cat /opt/restheart/etc/restheart.yml
greezlyk commented 8 years ago

Hello again, I am using now the configuration files restheart.yml and security.yml shipped with this repo, but still get the same issue. I manage to open blog and fetch data, but not post new blog entry.

mkjsix commented 8 years ago

If you want to run this with Docker more work is necessary. I'm now able to run it locally with Docker but I had to touch several files (e.g. the URL http://127.0.0.1:8080 is hardcoded everywhere while in my case docker runs at 192.168.99.100).

I'll update the project with some modifications to allow this running properly with Docker.

mkjsix commented 8 years ago

@greezlyk I added a docker-compose.yml which might help. Look at https://github.com/SoftInstigate/restheart-blog-example/blob/master/README.md#run-with-docker

Now everything works fine on my docker machine.

greezlyk commented 8 years ago

Thank you, it works for me now. In this case we have angular running inside docker restheart container. Could be more flexible if you put an external variable for resthear server in $http get post functions. So we can change the restheart ip address lately.

ujibang commented 8 years ago

You still have URL / bound to MongoDB resource * it must be URL /data bound to MongoDB resource *

this is set via mongo-mount option in configuration file.