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

Lack of detection of EOF (No automatic reconnection) #5

Closed
sigmonsays opened this issue Jul 12, 2012 · 4 comments
Closed

Lack of detection of EOF (No automatic reconnection) #5

sigmonsays opened this issue Jul 12, 2012 · 4 comments
Labels

Comments

@sigmonsays
Copy link

Not sure how reconnection or detection of failed network connections is supposed to work.. .but...

reader.go contains a bug in which it does not properly detect EOF.

This may be by design, however if you close(c) after the for {} loop, the user and use the coma, ok ("msg, ok := <-r") pattern to detect when the channel is closed and attempt a reconnect.

The fix is to close the input channel which will signal a closed channel to the receiver.

~ line 70 of func (c *Connection) reader() {

70 fmt.Println("Dead connection")
71 close(c.input)

Reconnection could be made automatic but it might be up to the caller to handle this also.

@gmallard
Copy link
Owner

Agreed that something more needs to be done when EOF is received attempt to accurately notify the caller. Thanks for the report.

I'll think about it this weekend. It might be more complex than just close(c.input) when the reader goroutine exits, especially for a 1.1 client.

Note however: reconnects, retries, fail overs, etc are totally a caller's responsibility.

@gmallard
Copy link
Owner

This is a very specific example of a more general problem.

Problem statement: package users are not being properly notified of network errors (including EOF) encountered during a read from the underlying net.Conn or tls.Conn.

The fix for this will address the general problem, including the specific case reported.

@gmallard
Copy link
Owner

Fixed: f0f8470

The read from the subscribe channel should complete with a MessageData that has a non-nil Error. In the particular case described, Error.Error() should be EOF.

Note that the package will subsequently treat this connection instance as dead, and no further operations may be performed with it.

@gmallard
Copy link
Owner

gmallard commented Jul 6, 2016

If you are still using the stompngo package please try the current v.1.0.2 tag.

Tag information:

b1f1d96 refs/tags/v1.0.2

Document that version number in any issue reports.

Thanks for the support.

Guy

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

No branches or pull requests

2 participants