无法解决 getaddrinfo EAI_AGAIN 错误
can't resolve getaddrinfo EAI_AGAIN error
我在 运行 我的 NodeJS 应用程序运行 20 分钟后出现此错误,此后它一直出现..它托管在 AWS (EC2) 我搜索了 getaddrinfo EAI_AGAIN 错误,应该是DNS问题,不知道怎么解决
WebSocket error: [object Object]
ErrorEvent {
target:
WebSocket {
_events:
[Object: null prototype] {
message: [Function: incoming],
disconnect: [Function],
close: [Function: close],
error: [Function] },
_eventsCount: 4,
_maxListeners: undefined,
_binaryType: 'nodebuffer',
_closeCode: 1006,
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: '',
_closeTimer: null,
_extensions: {},
_protocol: '',
_readyState: 2,
_receiver: null,
_sender: null,
_socket: null,
_bufferedAmount: 0,
_isServer: false,
_redirects: 0,
_url: 'wss://stream.binance.com:9443/ws/!bookTicker',
_req: null },
type: 'error',
message:
'getaddrinfo EAI_AGAIN stream.binance.com stream.binance.com:9443',
error:
{ Error: getaddrinfo EAI_AGAIN stream.binance.com stream.binance.com:9443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
errno: 'EAI_AGAIN',
code: 'EAI_AGAIN',
syscall: 'getaddrinfo',
hostname: 'stream.binance.com',
host: 'stream.binance.com',
port: '9443' } }
对于未来的读者,问题是因为Binance的web socket服务器要求在10分钟内响应ping帧,否则连接会断开,所以我得到1006错误,我用pong修复了这个问题像这样的框架:ws.pong();
否则你会得到一个 1008 错误代码。
示例:
const ws = new WebSocket('wss://stream.binance.com:9443/ws/!bookTicker');
ws.onopen = function(message) {
console.log("Connected: ");
ws.pong();
}
ws.on("ping", function(message) {
ws.pong();
});
我在 运行 我的 NodeJS 应用程序运行 20 分钟后出现此错误,此后它一直出现..它托管在 AWS (EC2) 我搜索了 getaddrinfo EAI_AGAIN 错误,应该是DNS问题,不知道怎么解决
WebSocket error: [object Object]
ErrorEvent {
target:
WebSocket {
_events:
[Object: null prototype] {
message: [Function: incoming],
disconnect: [Function],
close: [Function: close],
error: [Function] },
_eventsCount: 4,
_maxListeners: undefined,
_binaryType: 'nodebuffer',
_closeCode: 1006,
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: '',
_closeTimer: null,
_extensions: {},
_protocol: '',
_readyState: 2,
_receiver: null,
_sender: null,
_socket: null,
_bufferedAmount: 0,
_isServer: false,
_redirects: 0,
_url: 'wss://stream.binance.com:9443/ws/!bookTicker',
_req: null },
type: 'error',
message:
'getaddrinfo EAI_AGAIN stream.binance.com stream.binance.com:9443',
error:
{ Error: getaddrinfo EAI_AGAIN stream.binance.com stream.binance.com:9443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
errno: 'EAI_AGAIN',
code: 'EAI_AGAIN',
syscall: 'getaddrinfo',
hostname: 'stream.binance.com',
host: 'stream.binance.com',
port: '9443' } }
对于未来的读者,问题是因为Binance的web socket服务器要求在10分钟内响应ping帧,否则连接会断开,所以我得到1006错误,我用pong修复了这个问题像这样的框架:ws.pong();
否则你会得到一个 1008 错误代码。
示例:
const ws = new WebSocket('wss://stream.binance.com:9443/ws/!bookTicker');
ws.onopen = function(message) {
console.log("Connected: ");
ws.pong();
}
ws.on("ping", function(message) {
ws.pong();
});