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?) #357

Closed rohiddev closed 3 years ago

rohiddev commented 3 years ago

New to go and nats: I have started nats-server on my end:

[14409] 2021/08/01 19:44:16.499433 [INF] Starting nats-server
[14409] 2021/08/01 19:44:16.499574 [INF]   Version:  2.2.0-RC.8
[14409] 2021/08/01 19:44:16.499610 [INF]   Git:      [not set]
[14409] 2021/08/01 19:44:16.499637 [INF]   Name:     NDFKKSILFFRJP4USENPRH5URYBHVGN5LBFLXAO6QF6KUVCOMBJV36NIQ
[14409] 2021/08/01 19:44:16.499647 [INF]   ID:       NDFKKSILFFRJP4USENPRH5URYBHVGN5LBFLXAO6QF6KUVCOMBJV36NIQ
[14409] 2021/08/01 19:44:16.500362 [INF] Starting JetStream
[14409] 2021/08/01 19:44:16.500766 [WRN]     _ ___ _____ ___ _____ ___ ___   _   __  __
[14409] 2021/08/01 19:44:16.500776 [WRN]  _ | | __|_   _/ __|_   _| _ \ __| /_\ |  \/  |
[14409] 2021/08/01 19:44:16.500792 [WRN] | || | _|  | | \__ \ | | |   / _| / _ \| |\/| |
[14409] 2021/08/01 19:44:16.500795 [WRN]  \__/|___| |_| |___/ |_| |_|_\___/_/ \_\_|  |_|
[14409] 2021/08/01 19:44:16.500798 [WRN] 
[14409] 2021/08/01 19:44:16.500802 [WRN]       https://github.com/nats-io/jetstream
[14409] 2021/08/01 19:44:16.500805 [INF] 
[14409] 2021/08/01 19:44:16.500811 [INF] ---------------- JETSTREAM ----------------
[14409] 2021/08/01 19:44:16.500818 [INF]   Max Memory:      6.00 GB
[14409] 2021/08/01 19:44:16.500823 [INF]   Max Storage:     1.27 GB
[14409] 2021/08/01 19:44:16.500831 [INF]   Store Directory: "/var/folders/48/rfs8cvrd28z0grgt0rwn5ln00000gn/T/nats/jetstream"
[14409] 2021/08/01 19:44:16.500836 [INF] -------------------------------------------
[14409] 2021/08/01 19:44:16.501435 [INF] Listening for client connections on 0.0.0.0:4222
[14409] 2021/08/01 19:44:16.502056 [INF] Server is ready

Unable to send/receive messages: tried:

sc, err := stan.Connect("test", "test")

    if err != nil {
        log.Fatal(err)
    }

    // Simple Synchronous Publisher
    sc.Publish("foo", []byte("Hello World")) // does not return until an ack has been received from NATS Streaming

    // Simple Async Subscriber
    sub, err := sc.Subscribe("foo", func(m *stan.Msg) {
        fmt.Printf("Received a message: %s\n", string(m.Data))
    })

    if err != nil {
        log.Fatal(err)
    }

    // Unsubscribe
    sub.Unsubscribe()

Any help is much appeciated.

wallyqs commented 3 years ago

Hi, for stan.go you need to use the nats-streaming-server: https://github.com/nats-io/nats-streaming-server For JetStream, you can use https://github.com/nats-io/nats.go

rohiddev commented 3 years ago

thank you