旧的NodeJS客户端尝试连接到API时ENOTFOUND

时间:2018-08-03 08:13:08

标签: php node.js thrift

我必须通过url将我的nodejs节俭客户端连接到API。 当我这样做时,效果很好:

var thrift = require('thrift');
var Printf = require('./gen-nodejs/Printf');
const assert = require('assert');

var transport = thrift.TBufferedTransport;
var protocol = thrift.TBinaryProtocol;

var connection = thrift.createConnection("localhost",3000,{
 transport : transport,
 protocol : protocol
 });

connection.on('error', function(err) {
if(err) console.log(err.message);
});

这什么都不做,但是会连接到本地服务器。

但是当我尝试使用url时:

var thrift = require('thrift');
var Printf = require('./gen-nodejs/Printf');
const assert = require('assert');

var transport = thrift.TBufferedTransport;
var protocol = thrift.TBinaryProtocol;

var connection = thrift.createConnection("http://antares-clinic.ro:8125/medicalpages-api/php/test_api.php",8125,{
 transport : transport,
 protocol : protocol
 });

connection.on('error', function(err) {
if(err) console.log(err.message);
});

我收到此错误:getaddrinfo ENOTFOUND http://antares-clinic.ro:8125/medicalpages-api/php/test_api.php http://antares-clinic.ro:8125/medicalpages-api/php/test_api.php:8125

0 个答案:

没有答案