Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v4.3.0 #303

Merged
merged 33 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b55ae57
Make sure to try to reconnect when request to dispatcher fails
d-matsui Jan 7, 2021
79c18d0
Change example's sdk
skyway-ci-bot Jan 14, 2021
adc2dae
Add function to check example and readme
skyway-ci-bot Jan 14, 2021
c65d064
Remove latest from README.md
skyway-ci-bot Jan 14, 2021
0185464
add ssh key
skyway-ci-bot Jan 14, 2021
7a3e3f1
Add function to auto update website
skyway-ci-bot Jan 14, 2021
223154d
Fix lint
skyway-ci-bot Jan 14, 2021
2de41a1
Add test code
d-matsui Jan 14, 2021
836b911
Refactor check sdk
ibuibu Jan 15, 2021
6aa750f
Narrow down the scope of regex and fix check version
ibuibu Jan 15, 2021
2cedbe8
refactor and fix lint
ibuibu Jan 15, 2021
677d8ae
Add _getSignalingServerUrlWithRetry method to make sure to retry
d-matsui Jan 15, 2021
9ffa656
Add tests for socket._connectToNewServer()
d-matsui Jan 15, 2021
5148d13
Move an variable to config file.
d-matsui Jan 15, 2021
b59560f
Apply lint fix
d-matsui Jan 15, 2021
9add08d
Try changing servers up to 10 times.
d-matsui Jan 15, 2021
fa045d6
fix typo
d-matsui Jan 15, 2021
1119f35
Add tests for _getSignalingServerUrlWithRetry
d-matsui Jan 15, 2021
7276f55
Use assert.equal for checking error
d-matsui Jan 15, 2021
3889570
Merge pull request #298 from skyway/ops/auto-update-web
d-matsui Jan 17, 2021
9536a87
Undo changing config file
d-matsui Jan 18, 2021
59acd19
Rename a private method
d-matsui Jan 18, 2021
72d8b70
Update tests/peer/socket.js
d-matsui Jan 18, 2021
1e6d861
Merge pull request #297 from skyway/dev/socket-reconnect
y-i Jan 18, 2021
4e8b24f
Update changelog and sdk version.
d-matsui Jan 18, 2021
452fdbe
Remove module row from package.json
ibuibu Jan 19, 2021
0d5549b
Merge pull request #301 from skyway/ops/fix-package-json
y-i Jan 19, 2021
07b579b
update changelog
d-matsui Jan 19, 2021
7aef1cc
update release date
d-matsui Jan 19, 2021
b616afd
Merge pull request #300 from skyway/ops/changelog-4.3.0
d-matsui Jan 19, 2021
1734142
Update sdk version in readme and examples
d-matsui Jan 19, 2021
a5b5823
Update min.js in readme
d-matsui Jan 19, 2021
857b30b
Merge pull request #302 from skyway/ops/update-version
d-matsui Jan 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ jobs:
- run:
name: Install extra deps for CI
command: npm install --no-save replace-in-file@3.0.0 aws-sdk@2.597.0 @octokit/rest@16.36.0 @slack/client@5.0.2
- add_ssh_keys:
fingerprints:
- "56:a2:ef:d1:41:dd:99:a2:95:cf:df:a0:15:0e:6b:f1"
- run: node ./scripts/release-master

workflows:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## release note

## [v4.3.0](https://github.com/skyway/skyway-js-sdk/releases/tag/v4.3.0) - 2021-01-19

### Fixed

- Fixed a connecting process to signaling server so that `Peer` would reconnect when a request to the dispatcher server failed. ([#297](https://github.com/skyway/skyway-js-sdk/pull/297))
- Remove unnecessary module settings in package.json.

## [v4.2.0](https://github.com/skyway/skyway-js-sdk/releases/tag/v4.2.0) - 2020-12-22

### Added
Expand Down
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,13 @@
Add the following script tag to your html file.

```html
<script type="text/javascript" src="https://cdn.webrtc.ecl.ntt.com/skyway-latest.js"></script>
<script type="text/javascript" src="https://cdn.webrtc.ecl.ntt.com/skyway-4.3.0.js"></script>
```

You can then use the `Peer` object to start connecting.
For more details, check out the [Tutorial](https://webrtc.ecl.ntt.com/en/js-tutorial.html). ([日本語](https://webrtc.ecl.ntt.com/js-tutorial.html))

#### How to specify version and minified
By changing the file name, you can use each version and minified version.

Example
- Using version 4.2.0: `skyway-4.2.0.js`.
- Using minified version 4.2.0 : `skyway-4.2.0.min.js`.
- Using the latest minified version: `skyway-latest.min.js`.

#### CAUTION
When using `skyway-latest.js` and `skyway-latest.min.js`, when a new version of the SDK is released, the latest version will automatically be applied to your application. This makes it easy to keep up with browser updates, but depending on the changes in the SDK, your application may be affected.

To use the compressed version, add `.min` to the end of the file name, like `skyway-4.3.0.min.js`.

### Installing using npm to use with a bundler (e.g. webpack or browserify)

Expand Down
2 changes: 1 addition & 1 deletion examples/p2p-data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h1 class="heading">P2P Data example</h1>
</div>
<p class="meta" id="js-meta"></p>
</div>
<script src="//cdn.webrtc.ecl.ntt.com/skyway-latest.js"></script>
<script src="//cdn.webrtc.ecl.ntt.com/skyway-4.3.0.js"></script>
<script src="../_shared/key.js"></script>
<script src="./script.js"></script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion examples/p2p-media/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1 class="heading">P2P Media example</h1>
</div>
<p class="meta" id="js-meta"></p>
</div>
<script src="//cdn.webrtc.ecl.ntt.com/skyway-latest.js"></script>
<script src="//cdn.webrtc.ecl.ntt.com/skyway-4.3.0.js"></script>
<script src="../_shared/key.js"></script>
<script src="./script.js"></script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion examples/room/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h1 class="heading">Room example</h1>
</div>
<p class="meta" id="js-meta"></p>
</div>
<script src="//cdn.webrtc.ecl.ntt.com/skyway-latest.js"></script>
<script src="//cdn.webrtc.ecl.ntt.com/skyway-4.3.0.js"></script>
<script src="../_shared/key.js"></script>
<script src="./script.js"></script>
</body>
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "skyway-js",
"version": "4.2.0",
"version": "4.3.0",
"description": "The official JavaScript SDK for SkyWay",
"main": "dist/skyway.js",
"module": "src/peer.js",
"types": "skyway-js.d.ts",
"scripts": {
"test": "karma start ./karma.conf.js",
Expand Down
7 changes: 7 additions & 0 deletions scripts/release-master/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const isReleaseReady = require('./is-release-ready');
const publishToNpm = require('./publish-to-npm');
const publishToGitHub = require('./publish-to-github');
const notifySlack = require('./notify-slack');
const execSync = require('child_process').execSync;

(async function() {
const {
Expand Down Expand Up @@ -59,6 +60,12 @@ const notifySlack = require('./notify-slack');
return process.exit(0);
}

console.log('## Change sdk version on website');
const stdout = execSync(
`bash ./scripts/release-master/update-website.sh ${version}`
);
console.log(`stdout: ${stdout.toString()}`);

console.log('## Publish to npm');
await publishToNpm({ NPM_TOKEN });
console.log('');
Expand Down
47 changes: 47 additions & 0 deletions scripts/release-master/is-release-ready.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ module.exports = async function isReleaseReady(version) {
console.log('=> Yes. continue release steps');
console.log('');

console.log(`Script tag for v${version} exists in each example file?`);
const cond2 = isAllExampleSdkVersionURLCorrect(version);
if (!cond2) {
console.log('=> No. abort release steps');
console.log('');
return false;
}
console.log('=> Yes. continue release steps');
console.log('');

console.log(`v${version} exists in README.md?`);
const cond3 = isReadmeVersionURLCorrect(version);
if (!cond3) {
console.log('=> No. abort release steps');
console.log('');
return false;
}
console.log('=> Yes. continue release steps');
console.log('');

return true;
};

Expand All @@ -34,3 +54,30 @@ async function hasChangeLog(version) {
rl.once('close', () => resolve(false));
});
}

function isSdkVersionURLCorrect(version, filepath) {
const data = fs.readFileSync(filepath, 'utf8');
const matches = data.match(
/cdn\.webrtc\.ecl\.ntt\.com\/skyway-([0-9]+\.[0-9]+\.[0-9]+)(\.min)?\.js/g
);
for (const match of matches) {
if (!match.includes(version)) return false;
}
return true;
}

function isAllExampleSdkVersionURLCorrect(version) {
const examplePaths = [
'./examples/p2p-data/index.html',
'./examples/p2p-media/index.html',
'./examples/room/index.html',
];
for (const path of examplePaths) {
if (!isSdkVersionURLCorrect(version, path)) return false;
}
return true;
}

function isReadmeVersionURLCorrect(version) {
return isSdkVersionURLCorrect(version, './README.md');
}
29 changes: 29 additions & 0 deletions scripts/release-master/update-website.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

version=$1
BRANCH_WEBSITE='master'

# setup git
git config --global user.email "webrtc.skyway@gmail.com"
git config --global user.name "skyway-ci-bot"

# clone website repo
echo -e "StrictHostKeyChecking no\n" >> ~/.ssh/config
git clone -b $BRANCH_WEBSITE git@github.com:nttcom-webcore/skyway-official-web-site.git

# update version
cat skyway-official-web-site/docs/documents/javascript-sdk.md | grep ${version}
if [ "$?" -eq 0 ]; then
echo "Website is up to date. Skip updating website."
exit 0
fi
sed -i -e "s/skyway-[0-9]\{0,\}\.[0-9]\{0,\}\.[0-9]\{0,\}/${version}/g" skyway-official-web-site/docs/documents/javascript-sdk.md
sed -i -e "s/skyway-[0-9]\{0,\}\.[0-9]\{0,\}\.[0-9]\{0,\}/${version}/g" skyway-official-web-site/docs/en/documents/javascript-sdk.md

# deploy
cd skyway-official-web-site
git add -A
git commit -m 'Update js-sdk version'
git push origin $BRANCH_WEBSITE
echo 'Successful deployment!!'
exit 0
56 changes: 30 additions & 26 deletions src/peer/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,12 @@ class Socket extends EventEmitter {
}

if (this._dispatcherUrl) {
let serverInfo;
try {
serverInfo = await this._getSignalingServer();
this.signalingServerUrl = await this._fetchSignalingServerUrlWithRetry();
} catch (err) {
this.emit('error', err);
return;
}
const httpProtocol = serverInfo.secure ? 'https://' : 'http://';
this.signalingServerUrl = `${httpProtocol}${serverInfo.host}:${serverInfo.port}`;
}

this._io = io(this.signalingServerUrl, {
Expand All @@ -115,49 +112,56 @@ class Socket extends EventEmitter {
}

/**
* Connect to "new" signaling server. Attempts up to 10 times before giving up and emitting an error on the socket.
* @param {number} [numAttempts=0] - Current number of attempts.
* Connect to "new" signaling server.
* @return {Promise<void>} A promise that resolves with new connection has done.
* @private
*/
async _connectToNewServer(numAttempts = 0) {
// max number of attempts to get a new server from the dispatcher.
const maxNumberOfAttempts = 10;
if (
numAttempts >= maxNumberOfAttempts ||
this._reconnectAttempts >= config.numberServersToTry
) {
async _connectToNewServer() {
if (this._reconnectAttempts >= config.numberServersToTry) {
this.emit('error', 'Could not connect to server.');
return;
}

// Keep trying until we connect to a new server because consul can take some time to remove from the active list.
let serverInfo;
try {
serverInfo = await this._getSignalingServer();
this.signalingServerUrl = await this._fetchSignalingServerUrlWithRetry();
} catch (err) {
this.emit('error', err);
return;
}
this._io.io.uri = this.signalingServerUrl;
this._io.connect();
this._reconnectAttempts++;
}

if (this.signalingServerUrl.indexOf(serverInfo.host) === -1) {
const httpProtocol = serverInfo.secure ? 'https://' : 'http://';
this.signalingServerUrl = `${httpProtocol}${serverInfo.host}:${serverInfo.port}`;

this._io.io.uri = this.signalingServerUrl;
this._io.connect();
this._reconnectAttempts++;
} else {
this._connectToNewServer(++numAttempts);
/**
* Return signaling server url. This attempts trying up to maxNumberOfAttempts times before giving up then throw error.
* @return {String} A string of signaling server url.
*/
async _fetchSignalingServerUrlWithRetry() {
for (let attempts = 0; attempts < config.maxNumberOfAttempts; attempts++) {
const serverInfo = await this._fetchSignalingServer().catch(err => {
logger.warn(err);
});
if (
serverInfo &&
serverInfo.port &&
serverInfo.host &&
(!this.signalingServerUrl ||
this.signalingServerUrl.indexOf(serverInfo.host) === -1)
) {
const httpProtocol = serverInfo.secure ? 'https://' : 'http://';
return `${httpProtocol}${serverInfo.host}:${serverInfo.port}`;
}
}
throw new Error('Could not get signaling server url.');
}

/**
* Return object including signaling server info.
* @return {Promise<Object>} A promise that resolves with signaling server info
and rejects if there's no response or status code isn't 200.
*/
_getSignalingServer() {
_fetchSignalingServer() {
return new Promise((resolve, reject) => {
const http = new XMLHttpRequest();

Expand Down
4 changes: 4 additions & 0 deletions src/shared/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ const maxDataSize = 20 * 1024 * 1024;
// The minimum interval of using Room.send() is 100 ms
const minBroadcastIntervalMs = 100;

// max number of attempts to get a new server from the dispatcher.
const maxNumberOfAttempts = 10;

// Number of reconnection attempts to the same server before giving up
const reconnectionAttempts = 2;

Expand Down Expand Up @@ -88,6 +91,7 @@ export default {
maxChunkSize,
maxDataSize,
minBroadcastIntervalMs,
maxNumberOfAttempts,
reconnectionAttempts,
numberServersToTry,
sendInterval,
Expand Down
Loading