PDA

View Full Version : اررور Error: read ECONNRESET at TLSWrap.onStreamRead وقتی که کلاینت دیسکانکت میشه



plague
یک شنبه 01 اسفند 1400, 14:23 عصر
سلام
من یه سرور چت با نود دارم مینویسم و سرور رو با استفاده از pm2 ران کردم
کلاینت ها با socket.io به سرور چت نود متصل هستن
مشکلی که هست اینه که وقتی کلاینتی دیسکانکت میشه (با بستن مرورگر / تب یا حتی رفرش کردن )

این اررور به وجود میاد تو سرور و ریست میشه باعث میشه همه کاکشن ها به سرور از بین بره




0|chat | Error: read ECONNRESET
0|chat | at TLSWrap.onStreamRead (node:internal/stream_base_commons:220:20) {
0|chat | errno: -104,
0|chat | code: 'ECONNRESET',
0|chat | syscall: 'read'
0|chat | }



من تمام کد های چت رو حذف کردم فقط چند خط کد گزاشتم تو سرور که لاگ کنه وقتی یوزری کانکت و دیسکانکت میشه

const env = require('dotenv').config({ path: '.env' })
const https = require('https');
const fs = require('fs');

app = require('express.io')();

var options = {
key: fs.readFileSync( env.parsed.SSL_KEY),
cert: fs.readFileSync(env.parsed.SSL_CERT)
};
app.https(options).io();
console.log('|-> protocol : https ');



app.io.route('online' , function (req){
console.log(`| online socket -> ${req.socket.id}`);
})


app.io.route('disconnect', function(req) {
console.log(`|->****************** disconnect : ${req.socket.id}`);
});

var PORT = env.parsed.PORT || 8080
console.log(`|-> listining to port ${PORT} `);
app.listen(PORT );





بعد از چند بار بازو بسته کردن مرورگر بازم اتفاق افتاد ... لاگ pm2




/root/.pm2/logs/chat-out.log last 15 lines:
0|chat | |-> protocol : https
0|chat | |-> listining to port 8080

/root/.pm2/logs/chat-error.log last 15 lines:
0|chat | (node:19821) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
0|chat | (Use `node --trace-deprecation ...` to show where the warning was created)

0|chat | | online socket -> Z2z7m6D9OXKPGRVhbz4R
0|chat | |->****************** disconnect : H_1-d7sIm2oIvxzzbz4Q
0|chat | | online socket -> JrnLWbqN4luBtYg4bz4S
0|chat | | online socket -> ZSY1wIywMEdmUcALbz4T
0|chat | | online socket -> ugSg08DksJ73ld1Rbz4U
0|chat | |->****************** disconnect : ugSg08DksJ73ld1Rbz4U
0|chat | |->****************** disconnect : ZSY1wIywMEdmUcALbz4T
0|chat | Error: read ECONNRESET
0|chat | at TLSWrap.onStreamRead (node:internal/stream_base_commons:220:20) {
0|chat | errno: -104,
0|chat | code: 'ECONNRESET',
0|chat | syscall: 'read'
0|chat | }
PM2 | App [chat:0] exited with code [1] via signal [SIGINT]
PM2 | App [chat:0] starting in -fork mode-
PM2 | App [chat:0] online
0|chat | |-> protocol : https
0|chat | |-> listining to port 8080
0|chat | (node:19864) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
0|chat | (Use `node --trace-deprecation ...` to show where the warning was created)

plague
شنبه 14 اسفند 1400, 15:30 عصر
ظاهرا بخاطر پکیج خیلی قدیمی بود و با socket.io , exprsss نوشتم درست شد مشکل