xmppo / go-xmpp

Go XMPP Library (From Yasuhiro Matsumoto and based on the code from Russ Cox)
https://golang.org/
BSD 3-Clause "New" or "Revised" License
526 stars 170 forks source link

Close Recv() before closing connection #154

Closed mdosch closed 5 months ago

mdosch commented 1 year ago

Dear mattn,

I have a goroutine where I run Recv() to receive stanzas and e.g. reply to IQs. Sometimes I get the following output when closing my program:

2023/07/28 14:11:17 read tcp [CLIENT_IP]:58128->[SERVER_IP]:5223: use of closed network connection

It would be nice if go-xmpp would stop reading on the connection via Recv() function before closing the connection on Close() or would provide a way to cancel Recv() (if that's possible).

Best regards, Martin

ridhodo commented 1 year ago

i also face this issue

cevin commented 7 months ago

me too

mdosch commented 5 months ago

I made some changes and to the library and now this seems to be no more the case with the current development version. @ridhodo and @cevin can you confirm?

If the stream is closed there should be no more reading on a closed connection but Recv() will return an error (io.EOF) instead.