Google App EngineエンジンにカスタムNode.jsアプリケーションを正常にデプロイしました。しかし、接続しようとするとmongooseがタイムアウトするため、アプリを起動する際に問題が発生しています。誠実に、マングースは私のローカルマシンでまったく同じパラメータで接続します。Google App EngineにMongooseを接続する
私のMongoDBのURIの形式は次のとおりです。
mongodb://<dbuser>:<dbpassword>@xxxx.mlab.com:<portNumber>/db-name
URIが示すように
は、DBはMLABによってホストされています。 Google Cloud Platformのサンドボックスインスタンスです。私はしかし、Google Compute Engineでdbを配備しませんでした。私は単にmlabのセットアッププロセスを進めるときにGCPをホストすることにしました。私も同様の質問をしてきましたが、ほとんどの人には受け入れられた答えがありません。コメントの談話を受け入れる解決策なしで変えてください。
私の質問は、私のApp Engineインスタンスと上記のURIに接続しようとしたときのローカルコンピュータとの違いは何ですか?私がmlabをGCP問題でホストすることを選択したという事実はありますか? Amazon AWSでホストされることを選択した場合、それはまったく異なっていますか?問題の根本原因はなんですか?
参考のため、ここでの同様の質問は、私が見つけたです:
error connecting to mongodb with mongoose on google compute engine
Cannot connect to mongodb after app deploys on google app engine
また
、それは場合に役立ちます、MongoDBのは、 db、ビジネスモデル用、アプリケーションのExpress Session用のデータストア、socket.ioからの一時データの格納用に使用します。展開後のApp Engineから
エラースタックトレース:Googleクラウドシェルでローカルにアプリケーションを実行しているから
2017-10-18 02:13:46 default[20171017t215757] npm ERR! enoent ENOENT: no such file or directory, open '/app/package.json'
2017-10-18 02:13:46 default[20171017t215757] npm ERR! enoent ENOENT: no such file or directory, open '/app/package.json'
2017-10-18 02:13:46 default[20171017t215757] npm ERR! enoent This is most likely not a problem with npm itself
2017-10-18 02:13:46 default[20171017t215757] npm ERR! enoent and is related to npm not being able to find a file.
2017-10-18 02:13:46 default[20171017t215757] npm ERR! enoent
2017-10-18 02:13:46 default[20171017t215757]
2017-10-18 02:13:46 default[20171017t215757] npm ERR! Please include the following file with any support request:
2017-10-18 02:13:46 default[20171017t215757] npm ERR! /app/npm-debug.log
2017-10-18 02:23:41 default[20171017t215757] npm ERR! Linux 3.16.0-4-amd64
2017-10-18 02:23:41 default[20171017t215757] npm ERR! argv "/nodejs/bin/node" "/nodejs/bin/npm" "start"
2017-10-18 02:23:41 default[20171017t215757] npm ERR! node v6.11.3
2017-10-18 02:23:41 default[20171017t215757] npm ERR! npm v3.10.10
2017-10-18 02:23:41 default[20171017t215757] npm ERR! path /app/package.json
2017-10-18 02:23:41 default[20171017t215757] npm ERR! code ENOENT
2017-10-18 02:23:41 default[20171017t215757] npm ERR! errno -2
2017-10-18 02:23:41 default[20171017t215757] npm ERR! syscall open
エラースタックトレース:それは指摘されていますと、あなたはhttps://cloud.google.com/nodejs/getting-started/deploy-mongodb上の指示に従うことができ
/home/myuser/src/project-id/teammate-express-server/node_modules/mongodb/lib/mongo_client.js:421
throw err
^
MongoError: failed to connect to server [ds147454.mlab.com:47454] on first connect [MongoError: connection 1 to ds147454.mlab.com:47454 timed out]
at Pool.<anonymous> (/home/myuser/src/project-id/teammate-express-server/node_modules/mongodb-core/lib/topologies/server.js:336:35)
at emitOne (events.js:96:13)
at Pool.emit (events.js:188:7)
at Connection.<anonymous> (/home/myuser/src/project-id/teammate-express-server/node_modules/mongodb-core/lib/connection/pool.js:280:12)
at Connection.g (events.js:292:16)
at emitTwo (events.js:106:13)
at Connection.emit (events.js:191:7)
at Socket.<anonymous> (/home/myuser/src/project-id/teammate-express-server/node_modules/mongodb-core/lib/connection/connection.js:197:10)
at Socket.g (events.js:292:16)
at emitNone (events.js:86:13)
at Socket.emit (events.js:185:7)
at Socket._onTimeout (net.js:338:8)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)
実際にGCPでホストされていますか?つまり、Google Cloud Platformコンソールにログインし、GCEインスタンスを確認し、そのためにプロビジョニングされたVMサーバを見つけることができますか?その場合、どのファイアウォールルールが関連付けられていますか? – BrettJ
https://cloud.google.com/nodejs/getting-started/deploy-mongodbのドキュメントに従っていますか? – BrettJ