Skip to content

api Client EventStream; can not detect nomad server‘s disconnet,and reconnect to server automaticly #27133

@dw130

Description

@dw130

Nomad version

Output from nomad version
nomad newtest version

Operating system and Environment details

golang

Issue

api Client EventStream; can not detect nomad server‘s disconnet,and reconnect to server automaticly

Reproduction steps

config := api.DefaultConfig()
config.Address = url

client, err := api.NewClient(config)
if err != nil {
	return
}

defer client.Close()

topics := map[api.Topic][]string{
	//api.TopicJob:        {"*"},
	api.TopicAllocation: {"*"},
}

ctx, _ := context.WithCancel(context.Background())

stream, err := client.EventStream().Stream(ctx, topics, 0, &api.QueryOptions{})
if err != nil {
}

   
for {
	select {
	case events, ok := <-stream:
		if !ok {
			log.Infof("stream close")
		}
	case <-ctx.Done():
		log.Infof("Nomad Job stop")
	}
}

1 use these code to connect to nomad server
2 close nomad server
3 can not detect nomd disconnect event
4 restart the nomad server
5 can not rec any event for ever

Expected Result

Actual Result

Job file (if appropriate)

Nomad Server logs (if appropriate)

Nomad Client logs (if appropriate)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions