diff --git a/src/tardismachine.ts b/src/tardismachine.ts index 7c1b3fe..237ba74 100644 --- a/src/tardismachine.ts +++ b/src/tardismachine.ts @@ -1,7 +1,7 @@ import findMyWay from 'find-my-way' import http from 'http' import { clearCache, init } from 'tardis-dev' -import { App, TemplatedApp, WebSocket } from 'uWebSockets.js' +import { App, DISABLED, TemplatedApp, WebSocket } from 'uWebSockets.js' import { replayHttp, replayNormalizedHttp } from './http' import { replayNormalizedWS, replayWS, streamNormalizedWS } from './ws' @@ -37,7 +37,12 @@ export class TardisMachine { } as any this._wsServer = App().ws('/*', { - upgrade: (res, req, context) => { + compression: DISABLED, + maxPayloadLength: 512 * 1024, + idleTimeout: 24 * 60 * 60, + maxBackpressure: 5 * 1024 * 1024, + closeOnBackpressureLimit: true, + upgrade: (res: any, req: any, context: any) => { res.upgrade( { req }, req.getHeader('sec-websocket-key'), @@ -70,7 +75,7 @@ export class TardisMachine { ws.onclose() } } - }) + } as any) } public async start(port: number) { diff --git a/test/tardismachine.test.ts b/test/tardismachine.test.ts index 4818a02..aad565b 100644 --- a/test/tardismachine.test.ts +++ b/test/tardismachine.test.ts @@ -626,7 +626,7 @@ describe('tardis-machine', () => { ] const options = await Promise.all( - EXCHANGES.filter((e) => e !== 'binance-jersey').map(async (exchange) => { + EXCHANGES.filter((e) => e !== 'binance-jersey' && e !== 'huobi-dm-options' && e !== 'star-atlas').map(async (exchange) => { const exchangeDetails = await getExchangeDetails(exchange) const dataTypes: any[] = ['trade', 'trade_bar_10ms', 'book_change', 'book_snapshot_3_0ms'] @@ -672,7 +672,9 @@ class SimpleWebsocketClient { private isClosed = false constructor(url: string, onMessageCB: (message: string) => void, onOpen: () => void = () => {}) { this._socket = new WebSocket(url) - this._socket.on('message', onMessageCB) + this._socket.on('message', function (message: Buffer) { + onMessageCB(message.toString()) + }) this._socket.on('open', onOpen) this._socket.on('error', (err) => { console.log('SimpleWebsocketClient Error', err)