2013-05-27 81 views
1

我想在Windows上運行流星應用程序。我在本機上運行了本地mongodb,並且在我的系統上還設置了環境變量<b>MONGO_URL=mongodb://127.0.0.1:27017/sample</b>。流星應用程序仍然無法連接到它。可能是什麼問題。Meteor App無法連接到MongoDB?

下面是錯誤: -

C:\workspace\node-workspace\gm>meteor 
[[[[[ C:\workspace\node-workspace\gm ]]]]] 

=> `Meteor server running on: <b>http://127.0.0.1:3000/</b>` 

app/packages/mongo-livedata/mongo_driver.js:113 
     throw err; 
      ^
Error: failed to connect to [127.0.0.1:3002] 
    at Server.connect.connectionPool.on.server._serverState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongo 
db\connection\server.js:564:74) 
    at EventEmitter.emit (events.js:126:20) 
    at connection.on._self._poolState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connecti 
on_pool.js:124:15) 
    at EventEmitter.emit (events.js:99:17) 
    at Socket.errorHandler (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connection.js:465:1 
0) 
    at Socket.EventEmitter.emit (events.js:96:17) 
    at Socket._destroy.self.errorEmitted (net.js:329:14) 
    at process.startup.processNextTick.process._tickCallback (node.js:244:9) 
=> Exited with code: 1 
=> Meteor server restarted 

app/packages/mongo-livedata/mongo_driver.js:113 
     throw err; 
      ^
Error: failed to connect to [127.0.0.1:3002] 
    at Server.connect.connectionPool.on.server._serverState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongo 
db\connection\server.js:564:74) 
    at EventEmitter.emit (events.js:126:20) 
    at connection.on._self._poolState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connecti 
on_pool.js:124:15) 
    at EventEmitter.emit (events.js:99:17) 
    at Socket.errorHandler (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connection.js:465:1 
0) 
    at Socket.EventEmitter.emit (events.js:96:17) 
    at Socket._destroy.self.errorEmitted (net.js:329:14) 
    at process.startup.processNextTick.process._tickCallback (node.js:244:9) 
=> Exited with code: 1 
=> Meteor server restarted 

app/packages/mongo-livedata/mongo_driver.js:113 
     throw err; 
      ^
Error: failed to connect to [127.0.0.1:3002] 
    at Server.connect.connectionPool.on.server._serverState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongo 
db\connection\server.js:564:74) 
    at EventEmitter.emit (events.js:126:20) 
    at connection.on._self._poolState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connecti 
on_pool.js:124:15) 
    at EventEmitter.emit (events.js:99:17) 
    at Socket.errorHandler (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connection.js:465:1 
0) 
    at Socket.EventEmitter.emit (events.js:96:17) 
    at Socket._destroy.self.errorEmitted (net.js:329:14) 
    at process.startup.processNextTick.process._tickCallback (node.js:244:9) 
=> Exited with code: 1 
=> Your application is crashing. Waiting for file change. 

回答

2

鑑於堆棧跟蹤說,流星仍試圖連接到MongoDB實例上的端口3002,那麼無論你have't正確設置環境變量或您尚未重新加載cmd shell以獲取新值。

你是怎麼設定的MONGO_URL?如果通過系統屬性設置它或更新autoexec.bat,則需要重新加載cmd shell。

你可以看到當前的值是通過在cmd shell中鍵入什麼:

echo %MONGO_URL% 

然後將其設置爲當前ENV你可以這樣做:

set MONGO_URL=mongodb://127.0.0.1:27017/sample 
1

我知道它已經一段時間但是我遇到了同樣的問題(在7月13日),我沒有時間弄清楚,最終轉到了一個可以正常工作的Linux安裝。

但是最近我有一些時間回到它。下面是在谷歌這個問題的一些討論集團 - https://groups.google.com/forum/#!topic/meteor-talk/AE6GYrJImAo

我發現蒙戈DB過程中甚至沒有開始,mongo_runner.js內的一些矛盾......我的解決辦法是開始蒙戈手動

C:\Program Files (x86)\Meteor\mongodb\bin>mongod -port 3002 --dbpath C:\Users\username\project\.meteor\local\db 

上面的項目在需要的端口上啓動,併爲您的項目指定數據庫文件夾......在這之後,您將像往常一樣啓動meteor。

0

作爲版的0.7.1流星mongodb的端口是3001,而不是3002

端口通常爲1以上(2在舊版本的流星的情況下)大於流星其上運行的端口是。例如,如果Meteor在端口3000上運行,MongoDB將在端口3001上