错误:连接ETIMEDOUT - 在Meteor Server上与Google保持距离

时间:2016-07-13 11:00:47

标签: javascript google-maps meteor google-distancematrix-api

我使用谷歌在服务器端使用Meteor查找2点之间的距离和持续时间。它工作正常但突然发出了这个错误:

Error: connect ETIMEDOUT at Object.Future.wait (/root/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:398:15)
        at Object.call (packages/meteor/helpers.js:119:1)
        at Object.HTTP.get (packages/http/httpcall_common.js:50:1)
        at Object.calculateDistance (server/helper.js:351:1)
        at [object Object].getDistance (server/methods.js:147:1)
        at maybeAuditArgumentChecks (livedata_server.js:1698:12)
        at livedata_server.js:708:19
        at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
        at livedata_server.js:706:40
        at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
        - - - - -
        at errnoException (net.js:905:11)
        at Object.afterConnect [as oncomplete] (net.js:896:19)

这是我在服务器上的代码:

 var url = 'https://maps.google.com/maps/api/directions/json?language=en&origin='+origin+'&destination='+destination+'&sensor=false&key='+this.directionsApiKey;

 var result = Meteor.http.get(url);

 if(result.statusCode == '200' && result.content){

    var content = JSON.parse(result.content);

    if(content && content.routes && content.routes[0] && content.routes[0].legs && content.routes[0].legs[0]){

        var tmp = content.routes[0].legs[0];

        if(tmp.distance && tmp.distance.value){

            distance = tmp.distance.value;
        }
        if(tmp.duration && tmp.duration.value){

            duration = tmp.duration.value;
        }
    }
}

好像我的http请求超时..我把代码放在try catch中,但它不会成为catch部分。这可能是什么问题?

0 个答案:

没有答案