awslabs / amazon-kinesis-video-streams-webrtc-sdk-js

JS SDK for interfacing with the Amazon Kinesis Video Streams Signaling Service.
https://awslabs.github.io/amazon-kinesis-video-streams-webrtc-sdk-js/examples/index.html
Apache License 2.0
288 stars 143 forks source link

NodeJS - Outside of browser environment #274

Closed sirknightj closed 1 year ago

sirknightj commented 1 year ago

Issue #, if available:

https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-js/issues/115

Description of changes:

Testing

package.json ``` { "name": "js-sdk-test", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "amazon-kinesis-video-streams-webrtc": "^2.1.0" } } ```
index.js (some information redacted) ``` const SignalingClient = require('amazon-kinesis-video-streams-webrtc').SignalingClient; const Roles = require('amazon-kinesis-video-streams-webrtc').Role; try { let client = new SignalingClient({ channelARN: "arn:aws:kinesisvideo:us-west-2:x:channel/demo-channel/x", channelEndpoint: "wss://m-x.kinesisvideo.us-west-2.amazonaws.com", role: Roles.MASTER, region: 'us-west-2', credentials: { accessKeyId: "x", secretAccessKey: "x", sessionToken: "x", }, }); client.open(); console.log('FINISHED!') } catch (e) { console.error(e); } ```

And verified the new one worked by replacing the node_modules/amazon-kinesis-video-streams-webrtc/lib folder with the new one.

Before:

/Users/me/Downloads/js-sdk-test/node_modules/amazon-kinesis-video-streams-webrtc/lib/SignalingClient.js:108
                        this.websocket = new WebSocket(signedURL);
                                             ^

ReferenceError: WebSocket is not defined
    at SignalingClient.<anonymous> (/Users/me/Downloads/js-sdk-test/node_modules/amazon-kinesis-video-streams-webrtc/lib/SignalingClient.js:108:46)
    at step (/Users/me/Downloads/js-sdk-test/node_modules/tslib/tslib.js:141:27)
    at Object.next (/Users/me/Downloads/js-sdk-test/node_modules/tslib/tslib.js:122:57)
    at fulfilled (/Users/me/Downloads/js-sdk-test/node_modules/tslib/tslib.js:112:62)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on SignalingClient instance at:
    at SignalingClient.onError (/Users/me/Downloads/js-sdk-test/node_modules/amazon-kinesis-video-streams-webrtc/lib/SignalingClient.js:282:14)
    at /Users/me/Downloads/js-sdk-test/node_modules/amazon-kinesis-video-streams-webrtc/lib/SignalingClient.js:84:50
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

After:

FINISHED!

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.