NATS Client timeouts all the time
I use NATS but it keeps throwing NATSConnectionException. Not sure if something's wrong with the docker compose file. I mean I literally took it from their docs but still.
try
{
_connection = new ConnectionFactory().CreateConnection("nats://nats:4222");
}
catch (Exception ex)
{
Console.WriteLine();
}
try
{
_connection = new ConnectionFactory().CreateConnection("nats://nats:4222");
}
catch (Exception ex)
{
Console.WriteLine();
}
version: '3.9'
services:
consul-server:
image: hashicorp/consul:1.13.1
container_name: consul-server
restart: always
volumes:
- ./consul/server.json:/consul/config/server.json:ro
networks:
- hashicorp
ports:
- "8500:8500"
- "8600:8600/tcp"
- "8600:8600/udp"
command: "agent -bootstrap-expect=1"
nats:
image: nats
ports:
- "8222:8222"
command: "--cluster_name NATS --cluster nats://0.0.0.0:6222 --http_port 8222 "
networks:
- nats
nats-1:
image: nats
command: "--cluster_name NATS --cluster nats://0.0.0.0:6222 --routes=nats://ruser:T0pS3cr3t@nats:6222"
networks:
- nats
depends_on:
- nats
nats-2:
image: nats
command: "--cluster_name NATS --cluster nats://0.0.0.0:6222 --routes=nats://ruser:T0pS3cr3t@nats:6222"
networks:
- nats
depends_on:
- nats
networks:
hashicorp:
driver: bridge
nats:
name: nats
version: '3.9'
services:
consul-server:
image: hashicorp/consul:1.13.1
container_name: consul-server
restart: always
volumes:
- ./consul/server.json:/consul/config/server.json:ro
networks:
- hashicorp
ports:
- "8500:8500"
- "8600:8600/tcp"
- "8600:8600/udp"
command: "agent -bootstrap-expect=1"
nats:
image: nats
ports:
- "8222:8222"
command: "--cluster_name NATS --cluster nats://0.0.0.0:6222 --http_port 8222 "
networks:
- nats
nats-1:
image: nats
command: "--cluster_name NATS --cluster nats://0.0.0.0:6222 --routes=nats://ruser:T0pS3cr3t@nats:6222"
networks:
- nats
depends_on:
- nats
nats-2:
image: nats
command: "--cluster_name NATS --cluster nats://0.0.0.0:6222 --routes=nats://ruser:T0pS3cr3t@nats:6222"
networks:
- nats
depends_on:
- nats
networks:
hashicorp:
driver: bridge
nats:
name: nats
1 Reply
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View