File tree Expand file tree Collapse file tree
packages/microservices/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,18 +7,21 @@ import {
77 ERROR_EVENT ,
88 MESSAGE_EVENT ,
99 NO_MESSAGE_HANDLER ,
10+ TCP_DEFAULT_HOST ,
1011 TCP_DEFAULT_PORT ,
1112} from '../constants' ;
13+ import { JsonSocket } from '../helpers/json-socket' ;
1214import { CustomTransportStrategy , PacketId , ReadPacket } from '../interfaces' ;
1315import {
1416 MicroserviceOptions ,
1517 TcpOptions ,
1618} from '../interfaces/microservice-configuration.interface' ;
17- import { JsonSocket } from '../helpers/json-socket' ;
1819import { Server } from './server' ;
1920
2021export class ServerTCP extends Server implements CustomTransportStrategy {
2122 private readonly port : number ;
23+ private readonly host : string ;
24+
2225 private server : NetSocket ;
2326 private isExplicitlyTerminated = false ;
2427 private retryAttemptsCount = 0 ;
@@ -27,11 +30,14 @@ export class ServerTCP extends Server implements CustomTransportStrategy {
2730 super ( ) ;
2831 this . port =
2932 this . getOptionsProp < TcpOptions > ( options , 'port' ) || TCP_DEFAULT_PORT ;
33+ this . host =
34+ this . getOptionsProp < TcpOptions > ( options , 'host' ) || TCP_DEFAULT_HOST ;
35+
3036 this . init ( ) ;
3137 }
3238
3339 public listen ( callback : ( ) => void ) {
34- this . server . listen ( this . port , callback ) ;
40+ this . server . listen ( this . port , this . host , callback ) ;
3541 }
3642
3743 public close ( ) {
You can’t perform that action at this time.
0 commit comments