Skip to content

Commit b04d2bb

Browse files
bugfix(microservices): use host property in TcpServer
1 parent 098eb3b commit b04d2bb

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

packages/microservices/server/server-tcp.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff 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';
1214
import { CustomTransportStrategy, PacketId, ReadPacket } from '../interfaces';
1315
import {
1416
MicroserviceOptions,
1517
TcpOptions,
1618
} from '../interfaces/microservice-configuration.interface';
17-
import { JsonSocket } from '../helpers/json-socket';
1819
import { Server } from './server';
1920

2021
export 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() {

0 commit comments

Comments
 (0)