This error will usually occur if you're attempting to close a connection you've already closed. Make sure you're not accidentally calling a function which contains close multiple times.


A common cause for this would be a connection being closed due to some circumstances, then the same object may try to reconnect, fail, and then in your code there may be a timeout which attempts to close the same object again, despite it never having been established.


Generally, consider the circumstances in which you're attempting to close the connection, and whether it's both necessary, and also if the connection will be always be connected when you attempt to close it.