这是AWS Lambda函数中的代码:
var https = require('https');
exports.handler = (event, context, callback) => {
var params = {
host: "bittrex.com",
path: "/api/v1.1/public/getmarketsummaries"
};
var req = https.request(params, function(res) {
var test = res.toString();
console.log(JSON.parse(test));
//console.log(JSON.parse(res.toString()));
});
req.end();
};
错误:getaddrinfo ENOTFOUND https://bittrex.com https://bittrex.com:443 在errnoException(dns.js:28:10) 在GetAddrInfoReqWrap.onlookup [as oncomplete](dns.js:76:26)
我无法想象,请帮忙。其他解决方案无效。
答案 0 :(得分:4)
从主机中删除 #Tested on python3
import fileinput
import csv
import random
import glob
import os
textToSearch = 'Button1'
with open('dict.csv', 'r') as f:
reader = csv.reader(f)
your_list = list(reader)
path='F:\Release1'
type(path)
extension = 'xaml'
os.chdir(path)
result = [i for i in glob.glob('*.{}'.format(extension))]
for i in range(0,len(result)):
fileToSearch = path + '\\' + result[i]
tempFile = open( fileToSearch, 'r+' )
for line in fileinput.input( fileToSearch ):
if textToSearch in line :
print('Match Found')
else:
print('Match Not Found!!')
i=random.randint(0,717) #numbers of words in dic
textToReplace = str(your_list[i]).replace("'","").replace("[","").replace("]","")
tempFile.write( line.replace( textToSearch, textToReplace ) )
tempFile.close()
#
#
。要求已经说明你正在使用https / SSL。
答案 1 :(得分:2)
我修改了您的代码,以便在AWS Lambda Node.js 6.10中正常运行。我将Lambda超时设置为60秒进行测试。
最大的变化是添加“res.on('data',function(chunk){}:”和“res.on('end',function(){}”。
var https = require('https');
exports.handler = (event, context, callback) => {
var params = {
host: "bittrex.com",
path: "/api/v1.1/public/getmarketsummaries"
};
var req = https.request(params, function(res) {
let data = '';
console.log('STATUS: ' + res.statusCode);
res.setEncoding('utf8');
res.on('data', function(chunk) {
data += chunk;
});
res.on('end', function() {
console.log("DONE");
console.log(JSON.parse(data));
});
});
req.end();
};
答案 2 :(得分:0)
问题出在您的安全组中。看起来您的lambda无权解析DNS。检查lambda sec组是否启用了端口53 UDP和TCP。