Comments (9)
Yes, the stream completes.
I did a subscribe()
on activity$ and it fires the complete handler when using polling and it fires the error handler when using web sockets.
You are right that the catch isn't the actual problem.
The problem is that checkConnection
emits an error when the token expires.
When that happens the stream resulting from Observable.interval(this.pollingInterval).combineLatest(this.checkConnection())
will also emit the error, at that point the catch will swallow the error and continue with an empty stream which effectively completes it.
In the case of websockets, where there is no catch, the error will be instead emitted on activity$, also terminating it.
checkConnection works in other places in the code because there it is always re-invoked and a new stream is created, while in the case of activity$ it is only invoked once when running the constructor,
so once it emits an error it can never recover.
This is a very simplified version of the code which I hope will illustrate better what I'm trying to say 😄:
var ConnectionStatus = {
Online: 2,
ExpiredToken: 3
}
const connectionStatus$ = new Rx.BehaviorSubject(ConnectionStatus.Online);
checkConnection = () => {
let obs = connectionStatus$
.flatMap(connectionStatus => connectionStatus === ConnectionStatus.ExpiredToken ? Rx.Observable.throw(new Error("expired token")) : Rx.Observable.of(null));
return obs;
}
const fakeInterval$ = new Rx.Subject();
pollingGetActivity$ = fakeInterval$
.combineLatest(checkConnection())
.catch(error => Rx.Observable.empty());
pollingGetActivity$.subscribe(n => console.log(n[0]), error => console.log(error), () => console.log('completed'));
fakeInterval$.next(1);
fakeInterval$.next(2);
connectionStatus$.next(ConnectionStatus.ExpiredToken);
fakeInterval$.next(3);
connectionStatus$.next(ConnectionStatus.Online);
fakeInterval$.next(4);
if you run this you should see
1
2
complete
but no 3 and 4.
from botframework-directlinejs.
Any progress on this issue?
I am using websocket directline with token.
When token expires , I can successfully renew token, but no new message arrives chat window.
I have confirmed that ConnectionStatus goes back to online.
Also, I have confirmed that my server receives messages even after token renewal.
So it seems that incoming messages are dropped somewhere.
I am using prebuild version from MS CDN.
from botframework-directlinejs.
Please take a look at https://github.com/Microsoft/BotFramework-DirectLineJS/blob/ckk/workaroundthe403issue/src/directLine.ts - to work around this problem.
from botframework-directlinejs.
I haven't debugged through this, but that catch will not itself complete the stream.
Are you certain the stream is completing, or is it just that it doesn't emit new activities?
from botframework-directlinejs.
I'm facing the same issue. Any progress on this?
from botframework-directlinejs.
@roald-di have you find any workaround for this?
from botframework-directlinejs.
Sorry for not watching this issue earlier.
From what I am seeing in the code, when we hit "expired token", we just simply stop and connectionStatus$
become ConnectionStatus.ExpiredToken
.
From what I see on the Web Socket path at https://github.com/Microsoft/BotFramework-DirectLineJS/blob/1f5e00d76018cff27bbeef2d1d5dcbce946420aa/src/directLine.ts#L695, we are waiting until the web page reconnect with a new token.
On the REST polling path at https://github.com/Microsoft/BotFramework-DirectLineJS/blob/1f5e00d76018cff27bbeef2d1d5dcbce946420aa/src/directLine.ts#L604, we are stopped with ConnectionStatus.ExpiredToken
.
I didn't try out the real code yet and maybe I overlooked at something, I guess the behavior is correct right now.
Is it because the activity$
is not re-subscribed, thus, the reconnect
doesn't work as expected?
Could you guys tell me more about your expectations on the expired token reconnect story?
from botframework-directlinejs.
@roald-di - thanks for your sample. I looked at this issue and looks like to me that in the catch block, we create a new empty Observable which ends up producing the "complete". We are looking into this to figure out what would be a good way to fix this issue so that consumers of activity$ can resume after a token expiry.
from botframework-directlinejs.
This issue is fixed.
from botframework-directlinejs.
Related Issues (20)
- subscribe not working when using react-query HOT 4
- This repo is missing important files
- Automated Tests With BotFramework-DirectLineJS HOT 6
- Whether to support the wechat mini program HOT 1
- Hello, how to send by directline, the ID of my QA environment? HOT 2
- Please create an Offline DirectLine Emulation that is supported by Microsoft.
- DirectlineStreaming doesn't work with Node.js HOT 7
- Error with Power Virtual Agent: Site Missing code 403 from https://directline.botframework.com/v3/directline/conversations HOT 1
- DirectlineStreaming - Retrying connection after end HOT 5
- Update webpack target for modern Node HOT 1
- DirectLineStreaming: unhandled rejection from connectWithRetryAsync in activity$
- While sending attachment, activity API was not triggering using botframework-directlinejs HOT 2
- Post an activity with attachment occurs 502 HOT 3
- Attachements limitation and expiry on DirectLine HOT 1
- DirectlineStreaming: Errors on disconnect are written to console HOT 2
- networkInformation: Switching network type, then switching back again, results in RECONNECT_REJECTED HOT 1
- Angular 15 with botframework-directlinejs does not compile due to typings errors. HOT 3
- [Error] NetworkInformation, missing Interface. HOT 4
- Mocking the WebSocket URL for end to end testing using playwright/cypress. HOT 2
- Application crashes when refresh token returns an error HOT 2
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.
from botframework-directlinejs.