cisco-ce / jsxapi Goto Github PK
View Code? Open in Web Editor NEWJavaScript bindings for Cisco Collaboration Endpoint XAPI
Home Page: https://cisco-ce.github.io/jsxapi/
License: MIT License
JavaScript bindings for Cisco Collaboration Endpoint XAPI
Home Page: https://cisco-ce.github.io/jsxapi/
License: MIT License
In the jsxapi library the ssh keep alive by default is turned off. This is the default of the ssh2 library used by jsxapi. While this is not a big problem if your endpoint goes down gracefully, it is if it suddenly loses network connectivity. Basically your ssh session will just hang as might your nodejs application. If the endpoint comes back on a different ip address for what ever reason your ssh session will never recover meaning having to restart your application to recover your connection. The solution how ever is actual very simple. Just add the keepaliveInterval attribute to the connect object and your good to go. This enables ssh keepalives (in milliseconds). Just ensure you use an integer not a string for the timer. This will then generate a event error at disconnect allowing you to recover your ssh session how ever you see fit.
const xapi = jsxapi.connect('ssh://host.example.com', {
username: 'admin',
password: 'password',
keepaliveInterval: 4000
});
Ubuntu 22.04
node 16.14.2
jsxapi 5.1.1
Attempting to npm install
from node_modules/jsxapi
:
npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @types/[email protected]
npm ERR! node_modules/@types/jest
npm ERR! dev @types/jest@"^26.0.24" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional @types/jest@"^27.0.0" from [email protected]
npm ERR! node_modules/ts-jest
npm ERR! dev ts-jest@"^27.0.7" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @types/[email protected]
npm ERR! node_modules/@types/jest
npm ERR! peerOptional @types/jest@"^27.0.0" from [email protected]
npm ERR! node_modules/ts-jest
npm ERR! dev ts-jest@"^27.0.7" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/dstaudt/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/dstaudt/.npm/_logs/2022-08-03T19_45_11_981Z-debug-0.log
Using npm install --force
seems to work ok as a workaround.
Mentioned log file attached.
This should be possible:
const jsxapi = require('jsxapi');
const xapi = new Promise((resolve, reject) => {
jsxapi
.connect('somehost', { /* ... */ })
.on('error', reject)
.on('ready', resolve);
});
Right now you'd have to catch a reference to the xapi
instance inside the Promise
creator function and pass a lambda to the "ready" handler: .on('ready', () => { resolve(xapi); });
In some cases, the ssh connection becomes unresponsive.
This seems to be because we're not catching the end
event from the ssh stream.
Trying to use this as an ES6 import like this:
import * as XAPI from 'jsxapi';
And when I go to use it:
let jsxapi = XAPI;
this.deviceConnection = jsxapi.connect(`wss://${this.deviceIP}`, {
username: this.deviceAdminUsername,
password: this.deviceAdminPassword
})
.on('error', console.error)
.on('ready', async (xapi:any)=>{
console.log("WE'VE CONNECTED!")
xapi.close();
})
I get the following error:
Uncaught ReferenceError: Buffer is not defined
at generateAuthSubProto (ws.js:1:493)
at websocketConnect (ws.js:1:922)
at initBackend (browser.js:1:1069)
at Object.eval [as connect] (connect.js:1:1861)
at Index.connectToDevice (index.js:47:1)
at EmberCuiButton.clickHandler (ember-cui-button.js:185:1)
Any suggestions?
Hey Guys, i'm having a trouble while i'm doing an UI update.
i have a panel that i'm updating with new products list, but when its larger than 3 products this error shows up 'Connection terminated remotely'
do you guys have an idea how can i handle that ? i'm new working with cisco devices.
i'm not on vpn, im doing that local
i have this code as example
const jsxapi = require('jsxapi');
jsxapi
.connect('ssh://roomkitip', {
username: 'user',
password: 'password'
}).on('error', async (error) => {
console.log(error)
}).on('ready', async (xapi) => {
let products= [{
codigo: 'agua',
nome: 'Water',
}, {
codigo: 'cafe',
nome: 'Coffee',
}, {
codigo: 'cha',
nome: 'Tea',
}, {
codigo: 'suco',
nome: 'Juice',
}, {
codigo: 'coca',
nome: 'Coke',
},];
xapi.command('UserInterface Extensions Panel Save', { PanelId: 'concierge' },
`<Extensions>
<Version>1.1</Version>
<Name>Concierge</Name>
<Panel>
<Icon>Concierge</Icon>
<Color>#FF3D67</Color>
<Name>Concierge</Name>
<Type>Statusbar</Type>
<Page>
<Name>Concierge</Name>
${ produtos.map(el => {
return `<Row>
<Name>${el.nome}</Name>
<Widget>
<WidgetId>${el.codigo}</WidgetId>
<Type>Spinner</Type>
<Options>style=plusminus</Options>
</Widget>
</Row>`}).join('')}
</Page>
</Panel>
</Extensions>`).then(res => {
console.log('result => ', res)
}).catch(err => {
console.log('erro => ', err)
});
});
Registering a feedback expression must return a promise which is resolved when the registration (read: command) is successful. There are scenarios where it's important to know if the feedback expression is registered before continuing issuing commands. This requires a breaking API change, as the current API returns a cancellation handler function.
One possibility to retain backwards compatibility is to attach a promise to the returned function:
on(path, listener) {
log.info(`new feedback listener on: ${path}`);
const eventPath = normalizePath(path)
.join('/')
.toLowerCase();
this.eventEmitter.on(eventPath, listener);
const registration = this.xapi.execute('xFeedback/Subscribe', {
Query: normalizePath(path),
});
const off = () => {
registration.then(({ Id }) => {
this.xapi.execute('xFeedback/Unsubscribe', { Id });
});
this.eventEmitter.removeListener(eventPath, listener);
};
off.registration = registration;
// ^-- Add registration Promise to returned function
return off;
}
Having issue with xapi.status.on('Cameras', camerasListener) feedback event.
When SpeakerTrack status changes, for instance, xapi is throwing an unknown error without any details about it. The event does get fired, I do get the updated state in the listener function but right after, XAPI is throwing.
Create a browser-friendly bundle which is part of the release package, suitable for CDNs like unpkg. The browser bundle supports only the WebSocket protocol. Include both a regular and a minified version.
I know WebSocket in general supports it, but does jsxapi
provide a means to do it.
From what I can tell looking at the code, it doesn't appear to let us disable cert check?
Though, the most straightforward way to add that option is not obvious to me.
Any plans to pass in the values (not just optionID) from prompt?
Currently prompt only passes back FeedbackID, OptionId but not the choice value
From page 230: https://www.cisco.com/c/dam/en/us/td/docs/telepresence/endpoint/ce93/collaboration-endpoint-software-api-reference-guide-ce93.pdf
When creating an XAPI instance without passing additional options the constructor defaults to sealing the object (making the instance less mutable by not allowing new properties and changes to existing properties). However, when passing unrelated options in a second argument to the XAPI constructor the seal
option isn't properly defaulted to true
, and so instances aren't sealed.
Sealing should be opt-out, always.
It would be nice to have reconnect ability built into the library somewhere.
This would remove the need to have
xapi
.on('close', () => {})
.on('error', (error) => {});
with reconnect logic in client code.
Today, to have reconnect ability, you will have to have event listeners on close
and error
, which will create a new xapi
object, and re-register all feedbacks.
In cases where an endpoint is offline but the script is still running it generates a client socket uncaught exception. This is using SSH to long term monitor events from an endpoint. Error is below.
2018-09-04T17:28:19.330Z error: Error [ERR_UNHANDLED_ERROR]: Unhandled error. (client-socket)
at XAPI.emit (events.js:171:17)
at TSHBackend. (/Users/christno/WebstormProjects/walmartApp/node_modules/jsxapi/lib/xapi/index.js:126:13)
at TSHBackend.emit (events.js:182:13)
at DuplexPassThrough. (/Users/christno/WebstormProjects/walmartApp/node_modules/jsxapi/lib/backend/tsh.js:106:20)
at DuplexPassThrough.emit (events.js:182:13)
at Client. (/Users/christno/WebstormProjects/walmartApp/node_modules/jsxapi/lib/transport/ssh.js:106:15)
at Client.emit (events.js:182:13)
at Socket. (/Users/christno/WebstormProjects/walmartApp/node_modules/ssh2/lib/client.js:299:10)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
It doesn't mean that the project has to be written in TypeScript, an index.d.ts
file at the root would be a good start.
https://github.com/Microsoft/dts-gen
https://stackoverflow.com/a/47746553
https://stackoverflow.com/a/12695001
http://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html
http://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html
For introspection purposes and also because different devices may have slightly different values possible for the same command, being able to get the valuespaces would be really awesome.
xconfiguration
and xstatus
trigger feedback on changes, but they are also non-transient and can be fetched at any time. A very nice convenience method would be to allow binding a callback to configs and statuses which is invoked with the initial value, as well as being called back on changes.
Possible names are .bind()
or .subscribe()
. "Subscribe" might be a better fit, as "bind" implies more of an end-to-end data binding between elements.
Requirements:
.subscribe()
method which first registers feedback, then fetches the value.I'm trying to know when my macro activates so I can run some functions. I found this event handler:
xapi.Event.Macros.Macro.Activated.on(value =>{})
Which doesn't seem to be responding and, seems a little meta for the macro to know when it's been activated.
Any info on this?
Use the gh-pages
way of deploying the documentation/home site.
We can quite easily do proper integration testing internally, but I'd really like for this process to be publicly available for transparency.
Today, it is possible to end up with a case where, because of delayed execution, the error emitter is assigned after some of the error-emitting code has started to execute.
Example of delayed emitter assignment
const xapi = jsxapi.connect('ssh://localhost:99');
Promise.resolve(() => {
xapi.on('error', (err) => {
console.error(`xapi error: ${err}`);
});
});
Though this example is a bit contrived, it is easy to picture a more organic scenario where the code is "synchronous" ish, but is triggered in an asynchronous manner, thus not being executed before any other async logic.
We should investigate the possibility of moving the error emitter assignment so that it is possible to do before doing the initial commit.
An example, though not the final design, of such a solution, might be something like:
import Jsxapi from 'jsxapi';
const jsxapi = new Jsxapi();
jsxapi.on('error', err => console.log(err));
jsxapi.connect('ssh://localhost:99')
Setup Travis to allow releasing directly to npm
.
See npm Releasing (v2).
Doesn't look like there is any test for createSetResponse
(while there are some for createCommandResponse
or createGetResponse
).
While working no a feature in vega I noticed that xapi.config.set('BLAH Audio Output ConnectorSetup', 'Manual)
resolves while it should have rejected.
For arrays, both the entire array and individual nodes within the array are dispatched. This leads to listeners being fired multiple times and is confusing.
xapi.config.on('Audio Input Microphone', console.log);
yields:
{ id: '1', Mode: 'Off' } { Configuration: { Audio: { Input: [Object] } } }
[ { id: '1', Mode: 'Off' } ] { Configuration: { Audio: { Input: [Object] } } }
Dependencies have been rotting away. Need to update them to remove security vulnerabilities and to keep the repo maintanable.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.