C
C#

help

NATS Client timeouts all the time

Hhulkstance9/23/2022
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();
}


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
UUUnknown User9/23/2022
Message Not Public
Sign In & Join Server To View

Looking for more? Join the community!