ews-javascript-api
ews-javascript-api copied to clipboard
onDisconnect not called even lifetime over!
Hi, I have found that both of onDisconnect and onSubscriptionError not called, when I change my computer's network.
backgroud: I use StreamingSubscriptionConnection; lifetime is 1 minute; I have push onSubscriptionError and onDisconnect callback.
In most cases, I can subscribe to receive mail normally. If I run the program first, it runs normally; then I switch WiFi from a-wifi to b-wifi, and the b-wifi network is smooth, but ondisconnect is not triggered, and it will not be called even after the timeout. When this happens, my program is basically unrecoverable.

after change wifi :

I'm sorry to trouble you. I hope it can be solved as soon as possible。thanks!
I will have to try this and debug connection issues, will come back to this later
I will have to try this and debug connection issues, will come back to this later
Hi, I find a new bug recently, when I use SyncFolderItems to sync items every 5minutes, the log will end at before SyncFolderItems . Because I have log before and end at SyncFolderItems operation, I guess this is a bug too.
Could I config the connection timeout time ? I can't find any API associated to this.
I will have to try this and debug connection issues, will come back to this later
Today, the problem of syncfolderitems stuck again. I found that before the problem, there was an error of "error: read econnreset" in my computer log. I don't know the cause of the problem. I have followed your method in JS/ xhrdefault.js Set in options.timeout=15000 Now it doesn't work.
Hi, I find a new bug recently, when I use SyncFolderItems to sync items every 5minutes, the log will end at before SyncFolderItems . Because I have log before and end at SyncFolderItems operation, I guess this is a bug too.
Could I config the connection timeout time ? I can't find any API associated to this.
I should reply at here.I have read the fetch.js source to find why SyncFolderItems no return .
I have read the fetch source , I dought that the timeout don't work normally.
`FetchStream.prototype._runStream = function (url_data, url) {
var req = url_data.transport.request(url_data.urloptions, (function (res) {
// catch new cookies before potential redirect
if (Array.isArray(res.headers['set-cookie'])) {
for (var i = 0; i < res.headers['set-cookie'].length; i++) {
this.cookieJar.setCookie(res.headers['set-cookie'][i], url);
}
}
if ([301, 302, 303, 307, 308].indexOf(res.statusCode) >= 0) {
if (!this.options.disableRedirects && this.options.maxRedirects > this._redirect_count && res.headers.location) {
this._redirect_count++;
req.destroy();
this.runStream(urllib.resolve(url, res.headers.location));
return;
}
}
this.meta = {
status: res.statusCode,
responseHeaders: res.headers,
finalUrl: url,
redirectCount: this._redirect_count,
cookieJar: this.cookieJar
};
var curlen = 0,
maxlen,
receive = (function (chunk) {
if (curlen + chunk.length > this.options.maxResponseLength) {
maxlen = this.options.maxResponseLength - curlen;
} else {
maxlen = chunk.length;
}
if (maxlen <= 0) {
return;
}
curlen += Math.min(maxlen, chunk.length);
if (maxlen >= chunk.length) {
if (this.responseBuffer.length === 0) {
this.responseBuffer = chunk;
} else {
this.responseBuffer = Buffer.concat([this.responseBuffer, chunk]);
}
} else {
this.responseBuffer = Buffer.concat([this.responseBuffer, chunk], this.responseBuffer.length + maxlen);
}
this.drainBuffer();
}).bind(this),
error = (function (e) {
this.ended = true;
this.emit('error', e);
this.drainBuffer();
}).bind(this),
end = (function () {
this.ended = true;
if (this.responseBuffer.length === 0) {
this.push(null);
}
}).bind(this),
unpack = (function (type, res) {
var z = zlib['create' + type]();
z.on('data', receive);
z.on('error', error);
z.on('end', end);
res.pipe(z);
}).bind(this);
this.emit('meta', this.meta);
if (res.headers['content-encoding']) {
switch (res.headers['content-encoding'].toLowerCase().trim()) {
case 'gzip':
return unpack('Gunzip', res);
case 'deflate':
return unpack('InflateRaw', res);
}
}
res.on('data', receive);
res.on('end', end);
}).bind(this));
req.on('error', (function (e) { this.emit('error', e); }).bind(this));
if (this.options.timeout) { req.setTimeout(this.options.timeout, req.abort.bind(req)); } this.on('destroy', req.abort.bind(req));
if (this.options.payload) { req.end(this.options.payload); } else if (this.options.payloadStream) { this.options.payloadStream.pipe(req); this.options.payloadStream.resume(); } else { req.end(); } };`
I'm not good at nodejs, do you think the timeout work normally? Is it possible the "req" destroy but not callback ?
have you tried it using @ewsjs/xhr. it uses request which may have improved timeout support. I do see that request lib is recently being deprecated, I can try fix that later