Replace ws with uws (#2807)
* Replace ws with uws * fix indent * Adjust indentation * remove trailing space
This commit is contained in:
parent
6358a169fd
commit
67b7d3d3b6
|
@ -99,11 +99,11 @@
|
||||||
"style-loader": "^0.16.1",
|
"style-loader": "^0.16.1",
|
||||||
"utf-8-validate": "^3.0.1",
|
"utf-8-validate": "^3.0.1",
|
||||||
"uuid": "^3.0.1",
|
"uuid": "^3.0.1",
|
||||||
|
"uws": "^0.14.5",
|
||||||
"webpack": "^2.4.1",
|
"webpack": "^2.4.1",
|
||||||
"webpack-manifest-plugin": "^1.1.0",
|
"webpack-manifest-plugin": "^1.1.0",
|
||||||
"webpack-merge": "^4.1.0",
|
"webpack-merge": "^4.1.0",
|
||||||
"websocket.js": "^0.1.7",
|
"websocket.js": "^0.1.7"
|
||||||
"ws": "^2.1.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@kadira/storybook": "^2.35.3",
|
"@kadira/storybook": "^2.35.3",
|
||||||
|
|
|
@ -7,7 +7,7 @@ import redis from 'redis'
|
||||||
import pg from 'pg'
|
import pg from 'pg'
|
||||||
import log from 'npmlog'
|
import log from 'npmlog'
|
||||||
import url from 'url'
|
import url from 'url'
|
||||||
import WebSocket from 'ws'
|
import WebSocket from 'uws'
|
||||||
import uuid from 'uuid'
|
import uuid from 'uuid'
|
||||||
|
|
||||||
const env = process.env.NODE_ENV || 'development'
|
const env = process.env.NODE_ENV || 'development'
|
||||||
|
@ -273,12 +273,16 @@ if (cluster.isMaster) {
|
||||||
|
|
||||||
// Setup stream output to WebSockets
|
// Setup stream output to WebSockets
|
||||||
const streamToWs = (req, ws) => {
|
const streamToWs = (req, ws) => {
|
||||||
const heartbeat = setInterval(() => ws.ping(), 15000)
|
const heartbeat = setInterval(() => {
|
||||||
|
// TODO: Can't add multiple listeners, due to the limitation of uws.
|
||||||
ws.on('close', () => {
|
if (ws.readyState !== ws.OPEN) {
|
||||||
log.verbose(req.requestId, `Ending stream for ${req.accountId}`)
|
log.verbose(req.requestId, `Ending stream for ${req.accountId}`)
|
||||||
clearInterval(heartbeat)
|
clearInterval(heartbeat)
|
||||||
})
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ws.ping()
|
||||||
|
}, 15000)
|
||||||
|
|
||||||
return (event, payload) => {
|
return (event, payload) => {
|
||||||
if (ws.readyState !== ws.OPEN) {
|
if (ws.readyState !== ws.OPEN) {
|
||||||
|
|
14
yarn.lock
14
yarn.lock
|
@ -6671,10 +6671,6 @@ uid-number@~0.0.6:
|
||||||
version "0.0.6"
|
version "0.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"
|
resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"
|
||||||
|
|
||||||
ultron@~1.1.0:
|
|
||||||
version "1.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.1.0.tgz#b07a2e6a541a815fc6a34ccd4533baec307ca864"
|
|
||||||
|
|
||||||
uniq@^1.0.1:
|
uniq@^1.0.1:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff"
|
resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff"
|
||||||
|
@ -6765,6 +6761,10 @@ uuid@^3.0.0, uuid@^3.0.1:
|
||||||
version "3.0.1"
|
version "3.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1"
|
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1"
|
||||||
|
|
||||||
|
uws@^0.14.5:
|
||||||
|
version "0.14.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/uws/-/uws-0.14.5.tgz#67aaf33c46b2a587a5f6666d00f7691328f149dc"
|
||||||
|
|
||||||
v8flags@^2.0.10:
|
v8flags@^2.0.10:
|
||||||
version "2.0.11"
|
version "2.0.11"
|
||||||
resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.0.11.tgz#bca8f30f0d6d60612cc2c00641e6962d42ae6881"
|
resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.0.11.tgz#bca8f30f0d6d60612cc2c00641e6962d42ae6881"
|
||||||
|
@ -7067,12 +7067,6 @@ write@^0.2.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
mkdirp "^0.5.1"
|
mkdirp "^0.5.1"
|
||||||
|
|
||||||
ws@^2.1.0:
|
|
||||||
version "2.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/ws/-/ws-2.1.0.tgz#b24eaed9609f8632dd51e3f7698619a90fddcc92"
|
|
||||||
dependencies:
|
|
||||||
ultron "~1.1.0"
|
|
||||||
|
|
||||||
xdg-basedir@^2.0.0:
|
xdg-basedir@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-2.0.0.tgz#edbc903cc385fc04523d966a335504b5504d1bd2"
|
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-2.0.0.tgz#edbc903cc385fc04523d966a335504b5504d1bd2"
|
||||||
|
|
Reference in New Issue