I'm using Godot v3.0.6.stable.official.8314054
There are two problems caused by using StreamPeerTCP class.
I have a server written in Golang which accepts TCP connections. When a new connection is accepted, it is immediately closed by the server itself.
Then I have a Godot client which connects to the server by StreamPeerTCP. The connection status changes from 0 to 2 (NONE -> CONNECTING -> CONNECTED), there are no problems with connecting. The problems appear when the server closes the connection.
1) In docs there is a concrete proposal:
STATUS_NONE = 0 — The initial status of the StreamPeerTCP, also the status after a disconnect.
But when the server closes the connection, no changes to the status applied. It remains the same, STATUS_CONNECTED (I monitor this in _process, in every frame). And I don't know how to be notified of the disconnection from the server on the client (Godot) side.
2) An interesting behaviour one can see if it is a message with any data sent to the server by StreamPeerTCP when the connection is closed (as in my case). I use put_var("foo"). Know what? Godot engine just silently crashes. The program is closed and no any error messages are given. I didn't check some internal logs or whatever, but this behaviour is impermissible.
So the questions are: how to properly monitor disconnections from the external server and why behaviour declared in docs does not work? Does the latest unstable version of Godot corrects the issues?