Вторую ночь подряд падает Telegram бот, который по команде ищет письмо и выводит из него нужную информацию. Для работы с imap использую imap-simple.
Лог
2020-08-21T02:34:49: Error: This socket has been ended by the other party
2020-08-21T02:34:49: at Socket.writeAfterFIN [as write] (net.js:452:14)
2020-08-21T02:34:49: at JSStreamSocket.doWrite (internal/js_stream_socket.js:170:19)
2020-08-21T02:34:49: at JSStream.onwrite (internal/js_stream_socket.js:28:57)
2020-08-21T02:34:49: at TLSSocket.Socket._final (net.js:415:28)
2020-08-21T02:34:49: at callFinal (_stream_writable.js:609:10)
2020-08-21T02:34:49: at processTicksAndRejections (internal/process/task_queues.js:84:21) {
2020-08-21T02:34:49: code: 'EPIPE',
2020-08-21T02:34:49: source: 'socket'
2020-08-21T02:34:49: }
2020-08-21T02:34:52: ConnectionTimeoutError: connection timed out. timeout = 2000 ms
2020-08-21T02:34:52: at Connection.imapOnError (/home/asupportsdev/node_modules/imap-simple/lib/imapSimple.js:610:23)
2020-08-21T02:34:52: at Object.onceWrapper (events.js:417:26)
2020-08-21T02:34:52: at Connection.emit (events.js:310:20)
2020-08-21T02:34:52: at Timeout._onTimeout (/home/asupportsdev/node_modules/imap/lib/Connection.js:141:12)
2020-08-21T02:34:52: at listOnTimeout (internal/timers.js:549:17)
2020-08-21T02:34:52: at processTimers (internal/timers.js:492:7)
2020-08-21T02:34:56: ConnectionTimeoutError: connection timed out. timeout = 2000 ms
2020-08-21T02:34:56: at Connection.imapOnError (/home/asupportsdev/node_modules/imap-simple/lib/imapSimple.js:610:23)
2020-08-21T02:34:56: at Object.onceWrapper (events.js:417:26)
2020-08-21T02:34:56: at Connection.emit (events.js:310:20)
2020-08-21T02:34:56: at Timeout._onTimeout (/home/asupportsdev/node_modules/imap/lib/Connection.js:141:12)
2020-08-21T02:34:56: at listOnTimeout (internal/timers.js:549:17)
2020-08-21T02:34:56: at processTimers (internal/timers.js:492:7)
2020-08-21T02:35:00: ConnectionTimeoutError: connection timed out. timeout = 2000 ms
2020-08-21T02:35:00: at Connection.imapOnError (/home/asupportsdev/node_modules/imap-simple/lib/imapSimple.js:610:23)
2020-08-21T02:35:00: at Object.onceWrapper (events.js:417:26)
2020-08-21T02:35:00: at Connection.emit (events.js:310:20)
2020-08-21T02:35:00: at Timeout._onTimeout (/home/asupportsdev/node_modules/imap/lib/Connection.js:141:12)
2020-08-21T02:35:00: at listOnTimeout (internal/timers.js:549:17)
2020-08-21T02:35:00: at processTimers (internal/timers.js:492:7)
2020-08-21T02:35:03: ConnectionTimeoutError: connection timed out. timeout = 2000 ms
2020-08-21T02:35:03: at Connection.imapOnError (/home/asupportsdev/node_modules/imap-simple/lib/imapSimple.js:610:23)
2020-08-21T02:35:03: at Object.onceWrapper (events.js:417:26)
2020-08-21T02:35:03: at Connection.emit (events.js:310:20)
2020-08-21T02:35:03: at Timeout._onTimeout (/home/asupportsdev/node_modules/imap/lib/Connection.js:141:12)
2020-08-21T02:35:03: at listOnTimeout (internal/timers.js:549:17)
2020-08-21T02:35:03: at processTimers (internal/timers.js:492:7)
2020-08-21T02:35:07: ConnectionTimeoutError: connection timed out. timeout = 2000 ms
2020-08-21T02:35:07: at Connection.imapOnError (/home/asupportsdev/node_modules/imap-simple/lib/imapSimple.js:610:23)
2020-08-21T02:35:07: at Object.onceWrapper (events.js:417:26)
2020-08-21T02:35:07: at Connection.emit (events.js:310:20)
2020-08-21T02:35:07: at Timeout._onTimeout (/home/asupportsdev/node_modules/imap/lib/Connection.js:141:12)
2020-08-21T02:35:07: at listOnTimeout (internal/timers.js:549:17)
2020-08-21T02:35:07: at processTimers (internal/timers.js:492:7)
2020-08-21T02:35:11: ConnectionTimeoutError: connection timed out. timeout = 2000 ms
2020-08-21T02:35:11: at Connection.imapOnError (/home/asupportsdev/node_modules/imap-simple/lib/imapSimple.js:610:23)
2020-08-21T02:35:11: at Object.onceWrapper (events.js:417:26)
2020-08-21T02:35:11: at Connection.emit (events.js:310:20)
2020-08-21T02:35:11: at Timeout._onTimeout (/home/asupportsdev/node_modules/imap/lib/Connection.js:141:12)
2020-08-21T02:35:11: at listOnTimeout (internal/timers.js:549:17)
2020-08-21T02:35:11: at processTimers (internal/timers.js:492:7)
2020-08-21T02:36:51: Error: This socket has been ended by the other party
2020-08-21T02:36:51: at Socket.writeAfterFIN [as write] (net.js:452:14)
2020-08-21T02:36:51: at JSStreamSocket.doWrite (internal/js_stream_socket.js:170:19)
2020-08-21T02:36:51: at JSStream.onwrite (internal/js_stream_socket.js:28:57)
2020-08-21T02:36:51: at TLSSocket.Socket._final (net.js:415:28)
2020-08-21T02:36:51: at callFinal (_stream_writable.js:609:10)
2020-08-21T02:36:51: at processTicksAndRejections (internal/process/task_queues.js:84:21) {
2020-08-21T02:36:51: code: 'EPIPE',
2020-08-21T02:36:51: source: 'socket'
2020-08-21T02:36:51: }
Вчерашний лог идентичен, время приблизетельно такое же — 03:53:05. Смущает то, что данное явление происходит раз в сутки, и именно ночью, когда бот никем не используется. После каждой ошибки PM2 перезагрузил скрипт, но соеденение Imap не восстановилось до ручной перезагрузки.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
igorescobar opened this issue 9 years ago · comments
@pipobscure We’re now in production and now we’re getting this error sometimes:
Error: This socket has been ended by the other party
at Socket.writeAfterFIN [as write] (net.js:275:12)
at Object.ManagerAction (/opt/app/atendimento-painel/current/node_modules/asterisk-manager/lib/ami.js:284:22)
Do you have any idea why this is happening? This is a very critical problem for us!
Is it possible that the Asterisk server is closing the manager connection? Like are you restarting it or something of the sort?
It is all happening suddenly. There is no reason to the client or server close the connection. I just fire a command and wait for it to return eventually. Sometimes this happens and the client gets disconnected from the my socket.io.
Sent from my iPhone
On 09/04/2014, at 20:33, Philipp Dunkel notifications@github.com wrote:
Is it possible that the Asterisk server is closing the manager connection? Like are you restarting it or something of the sort?
—
Reply to this email directly or view it on GitHub.
I was wondering how does ami.js handle its socket connection and how can we recover fast from a abrupt error like this… I’m using NodeJS-AsteriskManager on a huge call center and only on production I’m getting this issue (maybe it’s because of the high-traffic). We are currently receiving about 50.000 calls/day and this errors are directly impacting our production environment…
I’m starting to think that this is a concurrency problem. Just like we had at #14
After digging into the problem I discovered that the problem wasn’t inside of NodeJS-AsteriskManager. Sorry! 👎
Hi igorescobar !
We’ve the same problem, can you tell how you solved it ?
Hi @fubaydullaev usually it’s a problem of software design (in your own app). I just re-wrote the part that my app was dealing with AMI and socket.io (simultaneously) and it worked like a charm. Maybe this is your case too.
I’m testing on 300 simultaneous calls with SIPP and it throughs that error, here is the code:
ami.on(‘confbridgejoin’, function(evt){
var now = new Date();
var data = {caller_id: evt.calleridnum,
caller_name: evt.calleridname,
number: evt.conference,
channel: evt.channel,
unique_id: evt.uniqueid,
start_time: now.toISOString()};
db.query("SELECT user_startmuted FROM conference WHERE del=0 AND number='"+evt.conference+"'", function(err, rows, fields) {
if (err) console.log(err);
if(rows.length > 0){
if(rows[0].user_startmuted == 'yes')
data.muted = 1;
}
});
if(data.caller_id == data.number) {
data.caller_id = caller_id;
data.caller_name = '';
}
db.query("SELECT tel, fio FROM addressbook WHERE tel='"+S(data.caller_id).left(-9)+"' LIMIT 1", function(err, rows, fields) {
if(rows.length > 0){
data.caller_id = rows[0].tel;
data.caller_name = rows[0].fio;
}
if (err) throw err;
db.query('INSERT INTO current SET ?', data, function(err, rows, fields) {
if (err) throw err;
});
});
});
Hi @fubaydullaev in this case maybe the problem is not inside of your callback but in a more broad context. How are you handling those connections? Did you use it along with socket.io or just AMI?
The more code you show the more I can help you
The rest is just actions/events
var express = require(‘express’);
var mysql = require(‘mysql’);
var S = require(‘string’);
var app = express();
// Config
app.set(‘port’, 3000);
app.set(‘asterisk_port’, 5038);
app.set(‘asterisk_ip’, ‘localhost’);
app.set(‘asterisk_username’, ‘admin’);
app.set(‘asterisk_password’, ‘password’);
var ami = new require(‘asterisk-manager’)(
app.get(‘asterisk_port’),
app.get(‘asterisk_ip’),
app.get(‘asterisk_username’),
app.get(‘asterisk_password’),
true); // This parameter determines whether events are emited.
// Routes
app.get(‘/’, function(req, res){
res.send(‘Asterisk Conference Manager 1.0 — by Uzdev’);
});
// Connect to Database
var db = mysql.createConnection({
host : ‘localhost’,
user : ‘root’,
password : ‘password’,
database : ‘cnfrnc’
});
db.connect();
is it a single file app? Post it all here, please.
yes this is single file app, and this is all the code, other part is just actions/events repeating, socket error appears when we’re testing 500 simultaneus calls for confbridgejoin only
I couldn’t see what is wrong with your code just by looking it. I got to write some stress tests and try to reproduce what you’re experiencing. 500 simultaneous calls is a lot of AMI events to manage. You are going to see this massage if the socket connection drops before de AMI had the change to call your callback and notify you about the event. When you tested that cenario did you checked the vitals of the Asterisk Server CPU/Memory/Disks etc.?
Is there any chance that you server connection could drop or be unaveilable during the 500 simultaneous calls?
@igorescobar is it possible to use cluster with ami events ?
Not as such, since it’s an outgoing connection. However you can collect
events in a main process and dispatch them onwards to a cluster of children.
On Thursday, May 22, 2014, fubaydullaev notifications@github.com wrote:
@igorescobar https://github.com/igorescobar is it possible to use
cluster with ami events ?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/17#issuecomment-43919685
.
Philipp Dunkel
UK +442034111097
US +17186736136
AU +61-2-80730500
AT +43-1-2297101
Can you please show the sample code ?
Have a look at https://www.npmjs.org/package/labourator which will do the children for you. This will allow you to do all the real work in the children leaving your main process to just handle the communication with asterisk
Thanks, what can you say about the issue «Error: This socket has been ended by the other party» ? Server has enough resource and it takes about 30-40% CPU, 5GB out of 32GB RAM
@fubaydullaev we’re talking about two machines right?
The one which is serving the asterisk communication and the one which is hosting this single file app you wrote. Or it’s all inside the same machine?
no they are both in the same machine and connected locally by 127.0.0.1 5038
@fubaydullaev The reason why you’re experiencing this issue is unknown for me. Only by trying to simulate that scenario I could detect the problem. Could be V8 memory limit?, memory leak?. The fact that your machine has plenty of memory doesn’t mean that your node process can handle it you need to dig into it. 500 active calls it is a lot to handle and I really recommend you to divide you traffic into more processes besides your master process. That can solve your problem… but if you have more time to dig into the problem memory limits/leak could be a good lead to the problem.
OBS: I’m considering that you already looked on all possibilities inside your logs in order to detect why the connection has suddenly dropped).
Sorry guys, if was our stupid mistake, after restarting asterisk we should have restart node as well so it was closing socket by aster Node.js and ami.js are handling issue awesome 👍 Thank you guys.
You could also renew the socket instance when asterisk restarts… So you don’t need to restart it manually
Sent from my iPhone
On 23/05/2014, at 15:23, fubaydullaev notifications@github.com wrote:
Sorry guys, if was our stupid mistake, after restarting asterisk we should have restart node as well so it was closing socket by aster
Node.js and ami.js are handling issue awesome Thank you guys.
—
Reply to this email directly or view it on GitHub.
Я переработал исходный код appium, добавлю свой код, когда я подключаюсь к порту, который перенаправляется на устройство и отправляет команду на порт, он выходит:
Error: This socket has been ended by the other party
и мой код выглядит так:
return await new Promise((resolve, reject) => {
try {
this.socketClient = net.connect(this.webSocket);
// Windows: the socket errors out when ADB restarts. Let catch it to avoid crashing.
this.socketClient.on('error', (err) => {
if (!this.ignoreUnexpectedShutdown) {
//throw new Error('Android bootstrap socket crashed: ${err}');
log.debug('//////////////////////////////////')
log.debug(err)
log.debug('//////////////////////////////////')
throw new Error('Android testbundle socket crashed: ${err}')
}
});
this.socketClient.once('connect', () => {
log.info("Android bundle socket is now connected");
resolve();
});
} catch (err) {
reject(err);
}
})
после этого я использую this.socketClient для отправки команды следующим образом:
async sendCommand(type, extra = {}) {
if (!this.socketClient) {
log.debug('==========socket closed========')
throw new Error('Socket connection closed unexpectedly');
}
return await new B((resolve, reject) => {
let cmd = Object.assign({cmd: type}, extra);
let cmdJson = '${JSON.stringify(cmd)}n';
log.debug('Sending command to android testbundle: ${_.trunc(cmdJson, 1000).trim()}');this.socketClient.write(cmdJson);
this.socketClient.setEncoding('utf8');let streamData = '';
this.socketClient.on('data', (data) => {
try {
streamData = JSON.parse(streamData + data);
// we successfully parsed JSON so we've got all the data,
// remove the socket listener and evaluate
this.socketClient.removeAllListeners('data');
if (streamData.status === 0) {
resolve(streamData.value);
}
log.debug("Received command result from bundle:" + JSON.stringify(streamData));
reject(errorFromCode(streamData.status));
} catch (ign) {
log.debug("Stream still not complete, waiting");
streamData += data;
}
})
})
}
Но, я всегда получаю ошибку:
[debug] [bundle] //////////////////////////////////
[debug] [bundle] Error: This socket has been ended by the other party
at Socket.writeAfterFIN [as write] (net.js:291:12)
at ..../lib/bundle.js:160:31
Любой может мне помочь…
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.