Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscriber issue w.r.t Golang client except 9292 none of the other ports are working. #65

Open
akshay071990 opened this issue Jul 27, 2020 · 3 comments

Comments

@akshay071990
Copy link

akshay071990 commented Jul 27, 2020

Hi Tyler,

In the below golang code:

package main

import (
	"context"
	"fmt"

	lift "github.com/liftbridge-io/go-liftbridge"
)

func main() {
	addr := "localhost:30276"
	client, err := lift.Connect([]string{addr})
	if err != nil {
		panic(err)
	}
	defer client.Close()

	ctx := context.Background()
	if err := client.Subscribe(ctx, "testpod-stream", func(msg *lift.Message, err error) {
		if err != nil {
			panic(err)
		}
		fmt.Println(msg.Timestamp(), msg.Offset(), string(msg.Key()), string(msg.Value()))
	}, lift.StartAtEarliestReceived()); err != nil {
		panic(err)
	}

	<-ctx.Done()
}


I am getting the error:
pc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp 0.0.0.0:9292: connect: connection refused"

So as you can see from my source code the port used is 30276 (Which is the node port of my liftbridge microservice) but the subscriber is trying to connect 9292. (The publisher example is working perfectly fine, just subscriber is giving this issue). Also this issue is not seen in JAVA subscriber client.
So is this a bug or do i need to make any other configurations? Can you pls help me!

Thanks
Akshay

@akshay071990 akshay071990 changed the title Subscriber issue w.r.t Golang client for other port except 9292 its not working. Subscriber issue w.r.t Golang client except 9292 none of the other ports are working. Jul 27, 2020
@tylertreat
Copy link
Member

Can you share your Liftbridge configuration? Also, are you running a single node or multiple Liftbridge nodes?

@akshay071990
Copy link
Author

akshay071990 commented Jul 28, 2020

Hi Tyler,

i am using single node k8s cluster deployed in my mac. Currently liftbridge has only one replicaset so there is only one leader and no followers. Using the Helmchart which is adapted from ("pozetroninc/liftbridge-helm-chart#3") the only change here i made is replica count is set to 1.

Also this issue is also seen if liftbridge is deployed as a binary with some other port say 9293, for that as well golang subscriber gives error as :

pc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp 0.0.0.0:9292: connect: connection refused"

for binary the configuration used is:

listen: localhost:9293
host: localhost
data.dir: /tmp/liftbridge/server-5
activity.stream.enabled: true

nats.servers:
  - nats://localhost:4222

streams:
  retention.max:
    age: 24h
    messages: 100
  compact.enabled: true

# Specify cluster settings.
clustering:
  server.id: server-5
  raft.bootstrap.seed: true
  replica.max.lag.time: 40s

if the port is changed to 9292 it works perfectly fine.

Thanks
AKshay

@tylertreat
Copy link
Member

The client is attempting to connect to port 9292 because this is the default port. Since port is not explicitly set in the config, the server is falling back to the default. host and port are used to specify the address that is advertised to the client, while listen is what the server binds to. Therefore, there are two ways you can fix this. You can either do the following:

# Explicitly specify the port to advertise
port: 9293

Or you can remove the host setting from the config. In this case, the value of listen will be returned to clients.

See more on these configs here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants