Skip to content

Commit

Permalink
[minor] Replace echo.websocket.org with websocket-echo.com
Browse files Browse the repository at this point in the history
The echo.websocket.org service is no longer available.
  • Loading branch information
lpinca committed Jan 9, 2022
1 parent ad3fe6d commit 91f3c07
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ can use one of the many wrappers available on npm, like
- [Multiple servers sharing a single HTTP/S server](#multiple-servers-sharing-a-single-https-server)
- [Client authentication](#client-authentication)
- [Server broadcast](#server-broadcast)
- [echo.websocket.org demo](#echowebsocketorg-demo)
- [Round-trip time](#round-trip-time)
- [Use the Node.js streams API](#use-the-nodejs-streams-api)
- [Other examples](#other-examples)
- [FAQ](#faq)
Expand Down Expand Up @@ -324,14 +324,12 @@ wss.on('connection', function connection(ws) {
});
```

### echo.websocket.org demo
### Round-trip time

```js
import WebSocket from 'ws';

const ws = new WebSocket('wss://echo.websocket.org/', {
origin: 'https://websocket.org'
});
const ws = new WebSocket('wss://websocket-echo.com/');

ws.on('open', function open() {
console.log('connected');
Expand All @@ -343,7 +341,7 @@ ws.on('close', function close() {
});

ws.on('message', function message(data) {
console.log(`Roundtrip time: ${Date.now() - data} ms`);
console.log(`Round-trip time: ${Date.now() - data} ms`);

setTimeout(function timeout() {
ws.send(Date.now());
Expand All @@ -356,9 +354,7 @@ ws.on('message', function message(data) {
```js
import WebSocket, { createWebSocketStream } from 'ws';

const ws = new WebSocket('wss://echo.websocket.org/', {
origin: 'https://websocket.org'
});
const ws = new WebSocket('wss://websocket-echo.com/');

const duplex = createWebSocketStream(ws, { encoding: 'utf8' });

Expand Down Expand Up @@ -457,7 +453,7 @@ function heartbeat() {
}, 30000 + 1000);
}

const client = new WebSocket('wss://echo.websocket.org/');
const client = new WebSocket('wss://websocket-echo.com/');

client.on('open', heartbeat);
client.on('ping', heartbeat);
Expand Down
6 changes: 2 additions & 4 deletions test/websocket.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ const WebSocket = require('..');

describe('WebSocket', () => {
it('communicates successfully with echo service (ws)', (done) => {
const ws = new WebSocket('ws://echo.websocket.org/', {
origin: 'http://www.websocket.org',
const ws = new WebSocket('ws://websocket-echo.com/', {
protocolVersion: 13
});
const str = Date.now().toString();
Expand All @@ -27,8 +26,7 @@ describe('WebSocket', () => {
});

it('communicates successfully with echo service (wss)', (done) => {
const ws = new WebSocket('wss://echo.websocket.org/', {
origin: 'https://www.websocket.org',
const ws = new WebSocket('wss://websocket-echo.com/', {
protocolVersion: 13
});
const str = Date.now().toString();
Expand Down
4 changes: 2 additions & 2 deletions test/websocket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('WebSocket', () => {
);

assert.throws(
() => new WebSocket('https://echo.websocket.org'),
() => new WebSocket('https://websocket-echo.com'),
/^SyntaxError: The URL's protocol must be one of "ws:", "wss:", or "ws\+unix:"$/
);

Expand All @@ -43,7 +43,7 @@ describe('WebSocket', () => {
);

assert.throws(
() => new WebSocket('wss://echo.websocket.org#foo'),
() => new WebSocket('wss://websocket-echo.com#foo'),
/^SyntaxError: The URL contains a fragment identifier$/
);
});
Expand Down

0 comments on commit 91f3c07

Please sign in to comment.