nginx-gridfs icon indicating copy to clipboard operation
nginx-gridfs copied to clipboard

nginx can`t access mongodb

Open FreedZou opened this issue 11 years ago • 19 comments

gridfs

I`ve installed nginx-gridfs module

when I access the picture,the result is error 404 and error_log of nginx like this:

2013/04/19 17:12:26 [error] 8349#0: *7658 Mongo connection dropped, could not reconnect, client: 221.226.28.34, server: localhost, request: "GET /xxoo/test.gif HTTP/1.1", host: "suishen.mobi"

Is the problem of the nginx-gridfs module?

I need help! Thanks!

the picture has been storaged in mongodb image

pic access url http://domain/xxoo/test.gif

nginx configure image

FreedZou avatar Apr 19 '13 09:04 FreedZou

Can you connect to that database using mongo shell?

mongo 10.1.1.1:30000/xxoo

eguven avatar Apr 19 '13 19:04 eguven

Same issue here. @eguven Yes, i am able to connect to that database using mongo shell.

Did you manage to find the solution to this?

alp82 avatar Jan 18 '14 21:01 alp82

me too , i have same problem, do you find the solution to this,i need your help

generalChow avatar Jan 24 '14 12:01 generalChow

I emailed the owner of this repository. It seems like he does not have time to work on current issues anymore. I will look into Riak CS as a drop-in replacement for MongoDB Gridfs.

alp82 avatar Jan 24 '14 12:01 alp82

Had the same problem Found commit 76225528b3903fc9eafcb8163c7ebfdf34237e8b works, my config:

location /grid/ {
    gridfs assets;
    mongo 172.16.1.154;
}

I notice at this stage it can't however resolve using avahi, only IP.

rdkls avatar Jan 31 '14 11:01 rdkls

@rdkls I am not sure how this is supposed to be a fix. The commit was already merged into master 2 years ago. What should i do if my config is:

location /grid/ {
    gridfs mediafiles field=filename type=string;
    mongo 172.16.1.154:27123;
}

alp82 avatar Feb 03 '14 20:02 alp82

Sorry for not fixing your problems =) It's something that works for me, at least. If I were you, I would check out that commit, recompile, and see if it works! Please also note the readme on the front of the repo - the owner is no longer actively maintaining it. So if you want something fixed - DIY.

rdkls avatar Feb 03 '14 21:02 rdkls

To fix the isseu you need the latest master branch of the C driver (the GridFS module uses another branch, which seems to be faulty).

After cloning this repo, do not do 'git submodule init && git subodule update', but instead: git clone https://github.com/eagleas/mongo-c-driver.git

Then compile nginx as usual.

assen-totin avatar Feb 23 '14 12:02 assen-totin

That's great assen73, thank you very much for your help.

alp82 avatar Feb 24 '14 10:02 alp82

thank you very much for assen73's help

mainliner avatar Mar 28 '14 06:03 mainliner

Guys, I might have stumbled onto something while playing with another MongoDB library, which is in pure C... I had a case much like this - the GridFS driver was seeing the file, but returning a size of 0 for it; it turned out that the file size in GridFS size was stored by some drivers as LongInt() and by others as Int(). On 64-bit platforms both work fine, but on 32-bit Little-endian platforms this breaks interoperability, because if the driver expects the size to be LongInt (64 bits), but it is Int (32 bits), then it often returns a size of 0. This means that the driver reading the GridFS should check how the size is stored and interpret it properly. I'm not sure if this is the case here, but it may be worth checking - as the fix will be easy.

assen-totin avatar Mar 28 '14 08:03 assen-totin

There are one problem is that you must delete the -Werror option of gcc in [nginx-source/objs/MakeFile]. If you don't do that, the warning will be treated as errors when you do make.

the log of make below:

cc1: warnings being treated as errors /home/Administrator/upload/nginx-gridfs//mongo-c-driver/src/numbers.c gcc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Wunused-function -Wunused-variable -Wunused-value -Werror -g --std=c99 -Isrc -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs
-o objs/ngx_modules.o
make[1]: *** [objs/addon/src/mongo.o] Error 1

mainliner avatar Mar 28 '14 08:03 mainliner

I got an error : nginx-gridfs/mongo-c-driver/src/bson.c:632:28: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] if ( pos + bytesNeeded <= b->dataSize ) how colud I do?

I do :git clone https://github.com/eagleas/mongo-c-driver.git
instead of 'git submodule init && git subodule update'

Have anyone help me?

ilaipi avatar Sep 11 '14 14:09 ilaipi

@mz0827 please use nginx1.4.7 or earlier version.

foxinmy avatar Apr 24 '15 09:04 foxinmy

@ilaipi you can refer to this issue: https://github.com/barakav/gridfs-nginx-plugin/issues/1

(to quote the answer in that thread: add (unsigned long) in the places there is a comparison issue to the int side. (if ( pos + bytesNeeded <= (unsigned long) b->dataSize )))

V-Alexeev avatar Sep 10 '15 17:09 V-Alexeev

i am trying this ..but getting the mongo connection drop error eventhough when i cloned git mongo-c-driver module instead of init and update.. I have a 64 bit ubuntu machine and using nginx 1.10.1 version of the nginx code.

sumantfordev avatar Aug 22 '16 13:08 sumantfordev

@sumantfordev I also encountered the same problem, the problem is that the mongo-c-driver driver,it can't use https://github.com/mongodb/mongo-c-driver.git Only use https://github.com/eagleas/mongo-c-driver.git

zhusas avatar Aug 26 '16 07:08 zhusas

Thanks i will give it a shot with it... Also is there any module to upload content to gridfs. Not looking to use lua but a direct nginx gridfs module as this one .. but to upload

sumantfordev avatar Aug 26 '16 14:08 sumantfordev

13:10:05 [error] 14472#0: *5 Mongo connection dropped, could not reconnect, client: 127.0.0.1, server: localhost, request: "GET /gridfs/label2.jpeg HTTP/1.1", host: "localhost" 2017/02/26 13:10:05 [alert] 14472#0: *5 header already sent while sending response to client, client: 127.0.0.1, server: localhost, request: "GET /gridfs/label2.jpeg HTTP/1.1", host: "localhost"

13:10:06 [error] 14472#0: *6 Mongo connection dropped, could not reconnect, client: 127.0.0.1, server: localhost, request: "GET /gridfs/label2.jpeg HTTP/1.1", host: "localhost" 2017/02/26 13:10:06 [alert] 14472#0: *6 header already sent while sending response to client, client: 127.0.0.1, server: localhost, request: "GET /gridfs/label2.jpeg HTTP/1.1", host: "localhost"`

have similiar issue, i'm using nginx1.11

weiztech avatar Feb 26 '17 06:02 weiztech