[Technical Questions] How to consistently expire directline token?
See original GitHub issueHello!
I have been working with botframework-webchat and directline-js for almost a year.
In our project we have implemented token renewal on connection status change to ExpiredToken
. But I have not been able to expire it consistently to be able to deploy changes to production as the I do not understand the behavior.
Subscribed to connection status changes:
const directLineOptions: DirectLineOptions = {
webSocket: config.webSocket,
token: config.token,
domain: config.domain,
};
directLine = createDirectLine(directLineOptions);
directLine!.connectionStatus$.subscribe(connectionStatusObserver);
const connectionStatusObserver = (status: ConnectionStatus) => {
switch (status) {
case ConnectionStatus.ExpiredToken:
// here i'm renewing conversation through server side with secret
// I have not found a way for directline to wait for the async
// token renewal before it immediately goes into Ended status.
store.dispatch(renewTokenRequest());
break;
case ConnectionStatus.Ended:
// indication that direct-line has disconnected/ended
store.dispatch(setDirectLineDisconnected(true));
// after that I try to re-create directline connection
break;
}
};
DirectlineJS documentation in readme
file:
If your app created your DirectLine object by passing a token, DirectLine will refresh that token every 15 minutes. Should your client lose connectivity (e.g. close laptop, fail to pay Internet access bill, go under a tunnel), connectionStatus$ will change to ConnectionStatus.ExpiredToken. Your app can request a new token from its server, which should call the Reconnect API. The resultant Conversation object can then be passed by the app to DirectLine.
By turning off internet connection for my PC the only thing in Chrome Developer Console is the bellow error message. Directline in this case does not trigger ExpiredToken
status at all.
ajax.js:129 OPTIONS https://europe.directline.botframework.com/v3/directline/tokens/refresh net::ERR_INTERNET_DISCONNECTED
To manually trigger the status I fiddle with directline object in memory by setting its’ token and conversation id to an old one (> few days). On next user activity directline does change to ExpiredToken
status.
I have read the whole documentation of directline V3 and I haven’t found the answers there.
Project setup:
- Create React App (boilerplate) + Redux + Redux Persist
- .NET MVC server side
- BotFramework-WebChat
The questions I have are:
- How long does a conversation stay available?
- How long does a conversation token live? What is the time period when it expires?
- How to expire the token from a user perspective consistently?
Best regards
Issue Analytics
- State:
- Created 4 years ago
- Comments:11
Top GitHub Comments
@avilde - I have access to the token service source code, so asking me is as good as asking a bot service developer.
You’ve shown me that 403 errors are being encountered when calling the
v3/directline/tokens/refresh
endpoint, but there are quite a few ways that a 403 error could be encountered when calling that endpoint. To know what specifically is going on, we’d need to know the message that came with the 403:Closing due to inactivity