diff --git a/CHANGELOG.md b/CHANGELOG.md
index ac8eabe5..6c141f41 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,8 @@
# Changelog
-## next
+## [v0.20.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.20.0)
+- fix(ws): concurrent websocket requests do not get upgraded ([#335](https://github.com/chimurai/http-proxy-middleware/issues/335))
- chore: drop node 6 (BREAKING CHANGE)
- chore: update to micromatch@4 ([BREAKING CHANGE](https://github.com/micromatch/micromatch/blob/master/CHANGELOG.md#400---2019-03-20))
- chore: update dev dependencies
diff --git a/examples/websocket/index.html b/examples/websocket/index.html
index 27519122..62ab2ecf 100644
--- a/examples/websocket/index.html
+++ b/examples/websocket/index.html
@@ -67,11 +67,13 @@
WebSocket demo
function connect() {
setupSocket(location.value);
+ toggleControls();
}
function disconnect() {
socket.close();
socket = undefined;
+ toggleControls();
}
function sendMessage(val) {
@@ -83,11 +85,9 @@ WebSocket demo
socket = new WebSocket(url);
socket.addEventListener('open', () => {
log('CONNECTED');
- toggleControls();
})
socket.addEventListener('close', () => {
log('DISCONNECTED');
- toggleControls()
})
socket.addEventListener('error', () => { log('SOCKET ERROR OCCURED'); })
socket.addEventListener('message', (msg) => { log('RECEIVED:' + msg.data); })
diff --git a/package.json b/package.json
index 2c96dfbc..e5a9b251 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "http-proxy-middleware",
- "version": "0.20.0-beta.2",
+ "version": "0.20.0",
"description": "The one-liner node.js proxy middleware for connect, express and browser-sync",
"main": "dist/index.js",
"files": [
diff --git a/src/http-proxy-middleware.ts b/src/http-proxy-middleware.ts
index e1a0d6fe..342e9da2 100644
--- a/src/http-proxy-middleware.ts
+++ b/src/http-proxy-middleware.ts
@@ -60,10 +60,12 @@ export class HttpProxyMiddleware {
};
private catchUpgradeRequest = server => {
- server.on('upgrade', this.handleUpgrade);
- // prevent duplicate upgrade handling;
- // in case external upgrade is also configured
- this.wsInternalSubscribed = true;
+ if (!this.wsInternalSubscribed) {
+ server.on('upgrade', this.handleUpgrade);
+ // prevent duplicate upgrade handling;
+ // in case external upgrade is also configured
+ this.wsInternalSubscribed = true;
+ }
};
private handleUpgrade = (req, socket, head) => {