Open Blendman974 opened 5 years ago
Check if it's sill reproducible with the current version, my PR changed how stuff get's handled.
(go get -u ...
)
I have managed to reproduce the issue as well (with the latest commit @irgendwr).
The issue happens when the connection times out/closes, but it isn't recognized by IsConnected()
.
For me, the issue comes from here:
https://github.com/multiplay/go-ts3/blob/master/client.go#L237
Pushing to c.work
blocks it, which in itself is caused because of this function call:
https://github.com/multiplay/go-ts3/blob/master/client.go#L208
c.process
freezes inside, when trying to call conn.Write()
.
:+1: But why does it freezes only while executed in a go routine ?
Check if this changes anything: https://github.com/irgendwr/go-ts3/commit/2516d1055a7a24e17ba953a5e8791690a51c29c8 (you'll have to copy the changes)
I'll test it out today, it'll probably work. But I think a better way to tackle this is to fix conn.Write()
freezing in the first place.
I fixed it on my end by doing:
if err == ts3Lib.ErrTimeout || err == ts3Lib.ErrNotConnected {
conn.Timeout()
} else if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
conn.Timeout()
}
You can apply the net.Error
check in the library codebase, and if it's true fix IsConnected()
I think a better way to tackle this is to fix
conn.Write()
freezing in the first place.
conn.Write
should not freeze longer than the specified timeout because SetWriteDeadline
is used.
It was likely freezing because the client was reading two responses (because no mutex was used) and then waiting for the response it already received until the deadline is reached.
DefaultTimeout
is 10 * time.Second
, if you want a shorter timeout set the option when creating a client:
client, err := NewClient(addr, Timeout(time.Millisecond*200))
You can apply the
net.Error
check in the library codebase
I'm not a maintainer btw, I have no permissions ^^
The program hangs when this api in repeatedly used in a go routine. See following code :