Skip to content

Commit

Permalink
removed idleTimeout, better error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
marcj committed Oct 10, 2019
1 parent 82cf46c commit 3f82b5e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ node_js:

services:
- mongodb
- redis-server

sudo: false

Expand Down
5 changes: 3 additions & 2 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"mongodb": "^3.3.2",
"reflect-metadata": "^0.1.12",
"rxjs": "~6.5.3",
"typeorm": "^0.2.18"
"typeorm": "^0.2.18",
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v16.0.0"
},
"dependencies": {
"@marcj/estdlib": "^0.1.11",
Expand All @@ -36,7 +37,6 @@
"redis": "^2.8.0",
"redlock": "^3.1.2",
"sift": "^7.0.1",
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v16.0.0",
"ws": "^6.1.2"
},
"devDependencies": {
Expand All @@ -57,6 +57,7 @@
"reflect-metadata": "^0.1.12",
"rxjs": "~6.5.3",
"source-map": "^0.7.3",
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v16.0.0",
"source-map-support": "^0.5.9",
"typeorm": "^0.2.18"
},
Expand Down
16 changes: 6 additions & 10 deletions packages/server/src/application-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ export class ApplicationServerConfig {
*/
mongoSynchronize: boolean = false;

redisHost: string = 'localhost';

redisPort: number = 6379;
exchangePort: number = 8561;

redisPrefix: string = 'glut';

Expand Down Expand Up @@ -149,9 +147,7 @@ export class ApplicationServer {
{provide: Application, useClass: this.application},
{provide: ApplicationServerConfig, useValue: this.config},
{provide: 'fs.path', useValue: this.config.fsPath},
{provide: 'redis.host', useValue: this.config.redisHost},
{provide: 'redis.port', useValue: this.config.redisPort},
{provide: 'redis.prefix', useValue: this.config.redisPrefix},
{provide: 'exchange.port', useValue: this.config.exchangePort},
{provide: 'mongo.dbName', useValue: this.config.mongoDbName},
{provide: 'mongo.host', useValue: this.config.mongoHost + ':' + this.config.mongoPort},
{
Expand All @@ -162,13 +158,13 @@ export class ApplicationServer {
{provide: Connection, useValue: this.connection},
{
provide: Exchange,
deps: [],
useFactory: () => new Exchange()
deps: ['exchange.port'],
useFactory: (port: number) => new Exchange(port)
},
{
provide: ExchangeServer,
deps: [],
useFactory: () => new ExchangeServer()
deps: ['exchange.port'],
useFactory: (port: number) => new ExchangeServer('127.0.0.1', port)
},
{
provide: Database, deps: [Connection, 'mongo.dbName'], useFactory: (connection: Connection, dbName: string) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/exchange-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ExchangeServer {
/* Options */
compression: 0,
maxPayloadLength: 50 * 1024 * 1024, //50mb
idleTimeout: 10,
idleTimeout: 0,
/* Handlers */
open: (ws, req) => {
console.log('new exchange client');
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ export class Exchange {
return new Promise<void>((resolve, reject) => {
this.socket = new WebSocket('ws://' + this.host + ':' + this.port);

this.socket.onerror = () => {
this.socket.onerror = (error: any) => {
this.socket = undefined;
reject(new Error('Error websocket'));
reject(new Error(`Could not connect to ${this.host + ':' + this.port}. Reason: ${error.message || error}`));
};

this.socket.onclose = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class Worker {
/* Options */
compression: 0,
maxPayloadLength: 2 * 100 * 1024 * 1024, //200mb
idleTimeout: 10,
idleTimeout: 0,
/* Handlers */
open: (ws, req) => {
const ip = Buffer.from(ws.getRemoteAddress());
Expand Down

0 comments on commit 3f82b5e

Please sign in to comment.