mirror of
https://github.com/Cameri/nostream.git
synced 2025-03-17 21:31:48 +01:00
chore: inc. pong timeout
This commit is contained in:
parent
48ca4fd9bf
commit
2a33d748e4
@ -1,7 +1,7 @@
|
||||
import ws, { WebSocket } from 'ws'
|
||||
import cluster from 'cluster'
|
||||
import { EventEmitter } from 'stream'
|
||||
import { IncomingMessage as IncomingHttpMessage } from 'http'
|
||||
import { WebSocket } from 'ws'
|
||||
|
||||
import { ContextMetadata, Factory } from '../@types/base'
|
||||
import { createNoticeMessage, createOutgoingEventMessage } from '../utils/messages'
|
||||
@ -22,7 +22,7 @@ import { Settings } from '../@types/settings'
|
||||
import { SocketAddress } from 'net'
|
||||
|
||||
(() => {
|
||||
(WebSocket as any).Receiver.prototype._write = function _write (chunk: any, _encoding: any, cb: any) {
|
||||
(ws as any).Receiver.prototype._write = function _write (chunk: any, _encoding: any, cb: any) {
|
||||
if (this._opcode === 0x08 && this._state == 0) return cb()
|
||||
|
||||
this._bufferedBytes += chunk.length
|
||||
@ -68,6 +68,8 @@ export class WebSocketAdapter extends EventEmitter implements IWebSocketAdapter
|
||||
family: address.indexOf(':') >= 0 ? 'ipv6' : 'ipv4',
|
||||
})
|
||||
|
||||
console.log(`web-socket-adapter: new client ${this.clientId} (${this.getClientAddress()})`)
|
||||
|
||||
this.client
|
||||
.on('error', (error) => {
|
||||
if (error.name === 'RangeError' && error.message === 'Max payload size exceeded') {
|
||||
@ -274,6 +276,6 @@ export class WebSocketAdapter extends EventEmitter implements IWebSocketAdapter
|
||||
this.removeAllListeners()
|
||||
this.client.removeAllListeners()
|
||||
|
||||
debug('client %s closed', this.clientId)
|
||||
console.error(`web-socket-adapter: disconnected client ${this.clientId} (${this.getClientAddress()})`)
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import { WebServerAdapter } from './web-server-adapter'
|
||||
|
||||
const debug = createLogger('web-socket-server-adapter')
|
||||
|
||||
const WSS_CLIENT_HEALTH_PROBE_INTERVAL = 30000
|
||||
const WSS_CLIENT_HEALTH_PROBE_INTERVAL = 60000
|
||||
|
||||
export class WebSocketServerAdapter extends WebServerAdapter implements IWebSocketServerAdapter {
|
||||
private webSocketsAdapters: WeakMap<WebSocket, IWebSocketAdapter>
|
||||
@ -95,6 +95,8 @@ export class WebSocketServerAdapter extends WebServerAdapter implements IWebSock
|
||||
return
|
||||
}
|
||||
|
||||
console.log('web-socket-server-adapter: connected clients:', this.webSocketServer.clients.size)
|
||||
|
||||
this.webSocketsAdapters.set(client, this.createWebSocketAdapter([client, req, this]))
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user