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

range over incoming eventually quits #15

Open
andrewwatson opened this issue Mar 3, 2017 · 4 comments
Open

range over incoming eventually quits #15

andrewwatson opened this issue Mar 3, 2017 · 4 comments

Comments

@andrewwatson
Copy link

I stole this chunk of code from one of your examples and then added a Println() call:

	// Receiver
	for m := range mqttClient.Incoming {
		fmt.Print(m.TopicName, "\t")
		m.Payload.WritePayload(os.Stdout)
		fmt.Println("\tr: ", m.Header.Retain)
	}

	fmt.Println("ran out of incoming")

and saw that if there weren't any messages for some period of time it would exit the for loop and my program would end.

Is this because of something on the mosquitto server closing my connection for being idle?

@jeffallen
Copy link
Owner

jeffallen commented Mar 3, 2017 via email

@andrewwatson
Copy link
Author

Yes, it's quite possible. I'm running this program on a Raspberry Pi in my office and connecting to a mosquitto running in AWS.

I'm trying to think of a better strategy for handling errors that may involve putting that range loop in another loop.

@andrewwatson
Copy link
Author

Could we export the Done channel from the client so that my program could be notified that it's shutdown and reconnect?

@jeffallen
Copy link
Owner

I am open to pull requests.

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