I am trying to run the second server with 5 docker servises builded with docker compose tool.And i am use another ports for that purpose.Main server is fine,but the second meets the error witn NUTS service. I have compose yaml config
version: "1"
services:
api-gateway:
build: ./api-gateway
restart: always
hostname: gateway
env_file:
- ./api-gateway/env/dev.env
ports:
- "8801:8801"
networks:
- lazar-network-dev-5
nats:
image: nats-streaming:0.17.0
ports:
- "4223:4223"
command: ["--port", "4223"]
networks:
- lazar-network-dev-5
volumes:
cache:
driver: local
networks:
lazar-network-dev-5:
name: lazar-network-dev-5
driver: bridge
attachable: true
After running it with compose up ,all containers starts up.
NATS give the following information:
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.399103 [INF] STREAM: Starting nats-streaming-server[test-cluster] version 0.17.0
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.399183 [INF] STREAM: ServerID: qM6kdWT3QBmVWutzKBt4Lj
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.399187 [INF] STREAM: Go version: go1.13.7
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.399189 [INF] STREAM: Git commit: [f4b7190]
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.401833 [INF] Starting nats-server version 2.1.4
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.401859 [INF] Git commit [fb009af]
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.402773 [INF] Listening for client connections on 0.0.0.0:4223
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.402791 [INF] Server id is NAIUYNZWKVEUHSGSKQ7PJKHMISK6E6UURECTY364J6MDLIKPIBCC4DFA
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.402793 [INF] Server is ready
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.441540 [INF] STREAM: Recovering the state...
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.441572 [INF] STREAM: No recovered state
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.692663 [INF] STREAM: Message store is MEMORY
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.692764 [INF] STREAM: ---------- Store Limits ----------
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.692771 [INF] STREAM: Channels: 100 *
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.692773 [INF] STREAM: --------- Channels Limits --------
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.692775 [INF] STREAM: Subscriptions: 1000 *
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.692777 [INF] STREAM: Messages : 1000000 *
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.692779 [INF] STREAM: Bytes : 976.56 MB *
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.692781 [INF] STREAM: Age : unlimited *
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.692783 [INF] STREAM: Inactivity : unlimited *
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.692786 [INF] STREAM: ----------------------------------
api5devtrapezaru-nats-1 | [1] 2024/02/20 07:34:10.692788 [INF] STREAM: Streaming Server is ready
Its seems to be ok,but when i try get query for the server NATS messaging about an error:
[Nest] 29 - 02/20/2024, 7:39:48 AM ERROR [ExceptionsHandler] CONNECTION_REFUSED
api5devtrapezaru-api-gateway-1 | NatsError: CONNECTION_REFUSED
api5devtrapezaru-api-gateway-1 | at Function.errorForCode (/app/node_modules/nats/nats-base-client/core.ts:168:12)
api5devtrapezaru-api-gateway-1 | at NodeTransport.<anonymous> (/app/node_modules/nats/src/node_transport.ts:94:21)
api5devtrapezaru-api-gateway-1 | at Generator.throw (<anonymous>)
api5devtrapezaru-api-gateway-1 | at rejected (/app/node_modules/nats/lib/src/node_transport.js:6:65)
api5devtrapezaru-api-gateway-1 | at processTicksAndRejections (node:internal/process/task_queues:95:5)
Calling NUTS from api-gateway
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
async function bootstrap(): Promise<void> {
const app = await NestFactory.create(AppModule);
const config = new DocumentBuilder()
.setTitle('Lazar API')
.setDescription('There will be description soon')
.setVersion('2.0')
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api', app, document);
app.connectMicroservice<MicroserviceOptions>({
transport: Transport.NATS,
options: {
servers: ['nats://nats:4223'],
},
});
await app.startAllMicroservices().catch((e) => console.log(e));
await app.listen(8801, () => {
console.log('Api-Gateway listening...');
});
}
bootstrap().catch((err: Error) => {
console.log(`${err.name}: ${err.message}`);
});
docker ls info
aee952b16abf
nats-streaming:0.17.0
"/nats-streaming-ser…"
9 minutes ago
Up 9 minutes
4222/tcp, 8222/tcp, 0.0.0.0:4223->4223/tcp, :::4223->4223/tcp