nats-io / stan.go

NATS Streaming System
https://nats.io
Apache License 2.0
706 stars 117 forks source link

stan: connect request timeout (possibly wrong cluster ID?) #369

Closed pratuljaingolang closed 1 year ago

pratuljaingolang commented 1 year ago

Hi I am new to NATS . I just started NATS cluster using Docker :-

docker run --name nats --network nats --rm -p 4222:4222 -p 8222:8222 nats --http_port 8222 --cluster_name event-cluster --cluster nats://0.0.0.0:6222

I got this response :-

[1] 2022/10/12 07:08:04.572545 [INF] Starting nats-server
[1] 2022/10/12 07:08:04.572712 [INF]   Version:  2.9.3
[1] 2022/10/12 07:08:04.572714 [INF]   Git:      [25e82d7]
[1] 2022/10/12 07:08:04.572715 [INF]   Cluster:  event-cluster
[1] 2022/10/12 07:08:04.572716 [INF]   Name:     NASQWCZGOYSIDK7TZCWVLTHU5JEKSUI7IE7KYKWI65APVXA4Y5KHHCFL
[1] 2022/10/12 07:08:04.572717 [INF]   ID:       NASQWCZGOYSIDK7TZCWVLTHU5JEKSUI7IE7KYKWI65APVXA4Y5KHHCFL
[1] 2022/10/12 07:08:04.573303 [INF] Starting http monitor on 0.0.0.0:8222
[1] 2022/10/12 07:08:04.573399 [INF] Listening for client connections on 0.0.0.0:4222
[1] 2022/10/12 07:08:04.573611 [INF] Server is ready
[1] 2022/10/12 07:08:04.573687 [INF] Cluster name is event-cluster
[1] 2022/10/12 07:08:04.573781 [INF] Listening for route connections on 0.0.0.0:6222

I tried putting this ID as cluster id in following stan connect code :- sc, err1 := stan.Connect("NASQWCZGOYSIDK7TZCWVLTHU5JEKSUI7IE7KYKWI65APVXA4Y5KHHCFL", "ASSWDewe")

I got this error :-

stan: connect request timeout (possibly wrong cluster ID?)

Kindly tell me what I am doing wrong here , as I put the ID that I got via running the NATS cluster . I also tried putting the cluster name for e.g. "event-cluster" and ID (as put above) as well.

Thanks in advance

pratuljaingolang commented 1 year ago

@kozlovic please help here.

kozlovic commented 1 year ago

@pratuljaingolang If you are new to NATS, and you need persistence, you should be looking at NATS Server with JetStream instead of NATS Streaming.

For that specific report, the issue is that you run the NATS Server, but use the NATS Streaming client to connect. Since the NATS Streaming server is not running, you get this error. Use the NATS Go client instead: https://github.com/nats-io/nats.go

pratuljaingolang commented 1 year ago

thanks @kozlovic , got your point.