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

How to share session with other nodes when one node shutdown suddenly #1840

Closed
xjg2010go opened this issue Jun 30, 2021 · 0 comments
Closed

Comments

@xjg2010go
Copy link

xjg2010go commented Jun 30, 2021

To help us save time and help you faster

Before opening a new issue, please make sure that there isn't already an open (or closed/resolved) issue reporting the same problem. Please always open a new issue rather than posting to a closed one - but please reference the possibly related old issue.

Please do not insert images of text, but add the text instead.

Environment

  • VerneMQ Version: 1.12
  • OS: centos 7
  • Erlang/OTP version (if building from source):
  • VerneMQ configuration (vernemq.conf) or the changes from the default:
  • Cluster size/standalone: 3

Expected behaviour

we want to keep session going on when one node in cluster lost connection

Actual behaviour

we deploy a new load balancer before vmq cluster and
When we use service vernemq stop in the node, our client lost subscribe session, only we resubscribe the message will show.

like this:
Received message: this is msg #58! from topic: vault
Received message: this is msg #59! from topic: vault
Received message: this is msg #60! from topic: vault
Received message: this is msg #61! from topic: vault
Received message: this is msg #62! from topic: vault
Received message: this is msg #63! from topic: vault
Received message: this is msg #64! from topic: vault
Connect lost: EOFConnected

Another new client:
Connected
Received message: this is msg #173! from topic: vault
Received message: this is msg #174! from topic: vault
Received message: this is msg #175! from topic: vault
Received message: this is msg #176! from topic: vault
Received message: this is msg #177! from topic: vault
Received message: this is msg #178! from topic: vault
Received message: this is msg #179! from topic: vault
Received message: this is msg #180! from topic: vault
Received message: this is msg #181! from topic: vault

my test code:

tlsConfig := NewTlsConfig()

opts := mqtt.NewClientOptions()

opts.AddBroker(fmt.Sprintf("ssl://%s:%d", broker, port))
opts.SetClientID("vernemq").SetTLSConfig(tlsConfig)
opts.SetUsername("123")
opts.SetPassword("123")
opts.SetAutoReconnect(true)

opts.SetDefaultPublishHandler(messagePubHandler)
opts.OnConnect = connectHandler
opts.OnConnectionLost = connectLostHandler
client := mqtt.NewClient(opts)
if token := client.Connect(); token.Wait() && token.Error() != nil {
	panic(token.Error())
}

// sub(client)
// publish(client)

//	go client.Subscribe("vault", 1, nil)

client.Subscribe("$share/group/vault", 1, nil)

i := 0
for range time.Tick(time.Duration(1) * time.Second) {
	if i == 5000 {
		break
	}
	text := fmt.Sprintf("this is msg #%d!", i)
	client.Publish("vault", 1, false, text)
	i++
}

client.Disconnect(250)

}

Question:

How to keep session persistent and share subscribe session in the venermq cluster,

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

No branches or pull requests

2 participants