문제 인식

image.png

🚫 문제점

원인 파악

Distributor 서비스에 연결하는 함수

  // TcpServer 클래스
  connectToDistributor(host, port, notification) {
    console.log('Connecting to distributor with:', { host, port });

    this.clientToDistributor = new TcpClient(
      host, // **<- 기존 host로 통신**
      port,
      ...
      ...
    );

gateway에 연결된 노드(서비스) 정보를 저장하는 함수

  // GatewayServer 클래스
  async onDistribute(data) {
    const connectServices = data.microservices.map((service) => {
      const node = service;
      const key = node.host + ':' + node.port;
      if (!this.mapClients.microservices[key] && node.name !== 'gateway') {
        const client = new TcpClient(
          node.host, // **<- 기존 host로 통신**
          node.port,
          (options) => {
				...
				...
				this.mapClients.microservices[key] = {
          client: client,
          info: node,
        };
        client.connect();
      }
    });

🔍 분석

해결 과정

Distributor 서비스에 연결하는 함수

  // Distributor에 연결
  connectToDistributor(host, port, notification) {
    console.log('Connecting to distributor with:', { host, port });

    this.clientToDistributor = new TcpClient(
      'distributor', // **<-** docker-compose에서 정의한 서비스 이름 사용
      port,
      ...
      ..
    );

gateway에 연결된 노드(서비스) 정보를 저장하는 함수