2013-12-10 92 views
1

我想使用meteor.http模塊,我在服務器端收到以下錯誤。 「錯誤:主機名/ IP與證書的altnames不匹配」,因爲我是Meteor和Node.js中的新手,並且它的javaScript調試很難(順便說一句,如何調試服務器端腳本?客戶端很容易)使用Mac OS X 10.9不知道這是否是培訓相關米......Meteor.http.get請求 - >錯誤:主機名/ IP不匹配證書的altnames

感謝 羅南

客戶端代碼:

'click #buildButton' : function() { 
    console.log("Jenkins job request"); 
    $('#buildButton').attr('disabled','true').val('loading...'); 
    var userName = "Ronen"; 
    Meteor.call('jenkinsServiceBuild', function(err, respJson) { 
    if(err) { 
     window.alert("Error: " + err.reason); 
     console.log("error occured on receiving data on server. ", err); 
    } else { 
     window.alert("Success: "); 
     console.log("respJson: ", respJson); 
     //window.alert(respJson.length + ' tweets received.'); 
     Session.set("recentTweets",respJson); 
    } 
    $('#buildButton').removeAttr('disabled').val('build'); 
    }); 
} 

服務器端代碼:

Meteor.methods({jenkinsServiceBuild: function(userName) { 
    var url = "https://www.ynet.co.il"; 
    //synchronous GET 
    var result = Meteor.http.get(url, {timeout:30000}); 
    if(result.statusCode==200) { 
    var respJson = JSON.parse(result.content); 
    console.log("response received."); 
    return respJson; 
    } else { 
    console.log("Response issue: ", result.statusCode); 
    var errorJson = JSON.parse(result.content); 
    throw new Meteor.Error(result.statusCode, errorJson.error); 
    } 
} 

});

回答

0

該網站'https://www.ynet.co.il'對該域有一個安裝不正確的SSL證書。它使用akamai的證書。

如果您瞭解並信任該網站和其沒有什麼太保護剛剛取下S在HTTPS

var url = "http://www.ynet.co.il"; 

而且我不知道該代碼將工作,看着現場它所服務的HTML內容,但這條線:

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

表明,它提供JSON內容。如果它確實服務器json內容使用此代替:

var respJson = result.data; 
+0

太棒了,你是對的它服務的JSON內容 – user3087483

相關問題