Comments (7)
@orgads - I'll be taking a look at this and will attempt a repro. Just to verify, can you please tell me which version of botframework-directlinejs
, axios, and Node you have installed?
from botframework-directlinejs.
Node 18, all the packages are latest. This is the dependencies part in package.json
{
"dependencies": {
"axios": "^1.2.2",
"botframework-directlinejs": "^0.15.1",
"xhr2": "^0.2.1"
}
}
from botframework-directlinejs.
@orgads - I was able to repro the issue. I'm currently researching it to try and identify where the specific failure is occuring and how it can be fixed or if there is a possible workaround. I will keep you posted.
from botframework-directlinejs.
For reference, here are the results of my repro noted above.
I used the customer's code with the exception of the observables. For those, I copied the code from the BotFramework-DirectLineJS readme doc just to ensure I was using tested code.
const XMLHttpRequest = require( 'xhr2');
const WebSocket = require( 'ws');
global.XMLHttpRequest = XMLHttpRequest;
global.WebSocket = WebSocket;
const crypto = require( 'crypto');
const { DirectLineStreaming, ConnectionStatus } = require('botframework-directlinejs');
const axios = require( 'axios');
const botUrl = 'https://some.site.azurewebsites.net/.bot/v3/directline';
const userId = crypto.randomUUID();
const username = `dl_ac_test-${userId.substring(0, userId.indexOf('-'))}`;
const botSecret = 'yEeoO.....FjSHI';
async function main() {
const data = { user: { id: username } };
const token = (
await axios.post('tokens/generate', data, {
baseURL: botUrl,
headers: { Authorization: `Bearer ${botSecret}` },
})
).data;
console.log('TOKEN ', token)
const directLine = new DirectLineStreaming({
// conversationId: token.conversationId,
token: token.token,
domain: botUrl,
// webSocket: true,
});
console.log('DIRECTLINE ', directLine)
directLine.connectionStatus$.subscribe(connectionStatus => {
switch (connectionStatus) {
case ConnectionStatus.Uninitialized: // the status when the DirectLine object is first created/constructed
console.log('CONNECTION STATUS: UNINITIATED');
break;
case ConnectionStatus.Connecting: // currently trying to connect to the conversation
console.log('CONNECTION STATUS: CONNECTING');
break;
case ConnectionStatus.Online: // successfully connected to the converstaion. Connection is healthy so far as we know.
console.log('CONNECTION STATUS: ONLINE');
break;
case ConnectionStatus.ExpiredToken: // last operation errored out with an expired token. Your app should supply a new one.
console.log('CONNECTION STATUS: EXPIRED TOKEN');
break;
case ConnectionStatus.FailedToConnect: // the initial attempt to connect to the conversation failed. No recovery possible.
console.log('CONNECTION STATUS: FAILED TO CONNECT');
break;
case ConnectionStatus.Ended: // the bot ended the conversation
console.log('CONNECTION STATUS: ENDED');
break;
}
});
directLine
.postActivity({
from: { id: 'myUserId', name: 'myUserName' }, // required (from.name is optional)
type: 'message',
text: 'a message for you, Rudy',
})
.subscribe(
id => console.log('Posted activity, assigned ID ', id),
error => console.log('Error posting activity', error)
);
directLine.activity$.subscribe(activity => console.log('received activity ', activity));
}
main();
When running, if directLine.postActivity()
is run first then I receive this error:
CONNECTION STATUS: UNINITIATED
CONNECTION STATUS: CONNECTING
C:\Users\Steven.Kanberg\Source\CustomerSubmits\DirectlineSteaming-386\node_modules\botframework-directlinejs\lib\directLineStreaming.js:363
return _this3.streamConnection.send(request);
^
TypeError: Cannot read properties of undefined (reading 'send')
at _callee4$ (C:\Users\Steven.Kanberg\Source\CustomerSubmits\DirectlineSteaming-386\node_modules\botframework-directlinejs\lib\directLineStreaming.js:363:50)
at tryCatch (C:\Users\Steven.Kanberg\Source\CustomerSubmits\DirectlineSteaming-386\node_modules\regenerator-runtime\runtime.js:64:40)
at Generator.invoke (C:\Users\Steven.Kanberg\Source\CustomerSubmits\DirectlineSteaming-386\node_modules\regenerator-runtime\runtime.js:299:22)
at Generator.next (C:\Users\Steven.Kanberg\Source\CustomerSubmits\DirectlineSteaming-386\node_modules\regenerator-runtime\runtime.js:124:21)
at asyncGeneratorStep (C:\Users\Steven.Kanberg\Source\CustomerSubmits\DirectlineSteaming-386\node_modules\@babel\runtime\helpers\asyncToGenerator.js:3:24)
at _next (C:\Users\Steven.Kanberg\Source\CustomerSubmits\DirectlineSteaming-386\node_modules\@babel\runtime\helpers\asyncToGenerator.js:25:9)
at C:\Users\Steven.Kanberg\Source\CustomerSubmits\DirectlineSteaming-386\node_modules\@babel\runtime\helpers\asyncToGenerator.js:32:7
at new Promise (<anonymous>)
at Observable.<anonymous> (C:\Users\Steven.Kanberg\Source\CustomerSubmits\DirectlineSteaming-386\node_modules\@babel\runtime\helpers\asyncToGenerator.js:21:12)
at Observable._subscribe (C:\Users\Steven.Kanberg\Source\CustomerSubmits\DirectlineSteaming-386\node_modules\botframework-directlinejs\lib\directLineStreaming.js:416:24)
However, if directLine.activity$.subscribe()
is ran first then I receive this error:
CONNECTION STATUS: UNINITIATED
CONNECTION STATUS: CONNECTING
Failed to connect Error: Unable to connect client to Node transport.
C:\Users\Steven.Kanberg\Source\CustomerSubmits\DirectlineSteaming-386\node_modules\botframework-streaming\lib\webSocket\nodeWebSocketClient.js:63
throw new Error(`Unable to connect client to Node transport.`);
^
Error: Unable to connect client to Node transport.
at WebSocketClient.<anonymous> (C:\Users\Steven.Kanberg\Source\CustomerSubmits\DirectlineSteaming-386\node_modules\botframework-streaming\lib\webSocket\nodeWebSocketClient.js:63:23)
at Generator.throw (<anonymous>)
at rejected (C:\Users\Steven.Kanberg\Source\CustomerSubmits\DirectlineSteaming-386\node_modules\botframework-streaming\lib\webSocket\nodeWebSocketClient.js:13:65)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
With both observables commented out, the DirectLine object is created and the connection status waits in the UNINITIATED
state.
Here is what the DirectLineStreaming object looks like, if of use:
{
'connectionStatus$': BehaviorSubject {
_isScalar: false,
observers: [ [Subscriber] ],
closed: false,
isStopped: false,
hasError: false,
thrownError: null,
_value: 0
},
_botAgent: 'DirectLine/3.0 (directlineStreaming)',
token: 'eyJhb.....dnurE',
domain: 'https://some.site.azurewebsites.net/.bot/v3/directline',
queueActivities: true,
'activity$': Observable {
_isScalar: false,
source: Observable {
source: [Observable],
subjectFactory: [Function: shareSubjectFactory]
},
operator: RefCountOperator { connectable: [Observable] }
}
}
While debugging, I noted the two following observations:
- When
connect()
is called in the NodeWebSocket class (ref here), thereq
object'sres
property is showingnull
. With my limited knowledge on the inner workings of web sockets, I don't know if this is expected or not. - The
this.wsSocket
property is showing asundefined
on line 101. This property is initiated as undefined in the class's constructor and I am unable to access thethis.wsSocket = websocket
assignment taking place within thecompleteUpgrade()
method. I can't verify if an assignment is actually taking place, so I'm unsure if this is processing correctly.
In either case, the promise on line 105 is returning an error. The issue may be tied to something else, but this is what I noted.
from botframework-directlinejs.
Closing this due to inactivity. Feel free to reopen
from botframework-directlinejs.
Please reopen. The issue is not resolved.
from botframework-directlinejs.
Superseded by microsoft/botbuilder-js#4412.
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.
- 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.