Closed torniker closed 3 years ago
So you are running a separate NATS cluster and Streaming cluster? Are you streaming servers connecting to the NATS cluster?
Note: if you are going to not configure the NATS connection, you don't need to have the 2 steps of creating the NATS connection then the STAN one. Remove nats.Connect()
and simply do:
sc, err := stan.Connect(clusterID, clientID, stan.NatsURL("nats://localhost:4222"))
if err != nil {
panic(fmt.Sprintf("could not connect to stan with clusterID \"%s\" and clientID: \"%s\" here is error: %s\n", clusterID, clientID, err))
}
The reason I asked if STAN is connecting to NATS is because if your STAN deployment does not, then the port you need to use is likely 7777, the one you use for STAN. If STAN is connecting to the NATS Server/cluster, then the port to use is indeed the one from NATS, which based on your config seem to be 4222.
Update:
I had installed nats and stan using basic streaming setup
# Single server NATS
kubectl apply -f https://raw.githubusercontent.com/nats-io/k8s/master/nats-server/single-server-nats.yml
kubectl apply -f https://raw.githubusercontent.com/nats-io/k8s/master/nats-streaming-server/single-server-stan.yml
I've uninstalled and installed it using helm charts and now it works...
But you see that those instructions were about "single server", both NATS and STAN. So with that setup you would get 2 independent NATS setups, and your STAN client should have connected to 7777, not 4222.
Anyway, since you get things working now, I am closing this issue.
I cannot connect to Stan server, which is running in remote Kubernetes cluster, from my local machine.
I run 2 port forward commands:
here is my code:
and I get following error:
The cluster ID is correct. When I run the same code (of course nats URL is different) in cluster as a pod everything works fine. But for development purposes I need to connect to stan server from local.