Closed Nicoretti closed 1 year ago
@littleK0i I was wondering if you've encountered this before. If so, could you provide additional context regarding this?
This error is supposed to be extremely rare. If it reproduces consistently, it means that something was changed on Exasol server side. Over these years I had multiple iterations on "closing" problem.
Initially I was just calling .close()
on WebSocket client. It worked, but it produced some error messages in SQLProcess logs, and it caused sessions to linger in internal Exasol system views for some time.
So I've changed it to sending disconnect
command first, followed by .close()
on WebSocket client. It helped older versions of Exasol to clean up sessions properly.
Since the application can be in undefined state when calling __del__
, the .close()
call must be wrapped in to try ... except ... pass
, just in case if socket is no longer available.
But normal calls to .close()
should be just fine, if both client and server function correctly.
I guess, now when we send disconnect
command from client, Exasol server terminates WebSocket connection immediately. But it should probably send CLOSE
frame to client or wait to receive CLOSE
frame from client, as per WebSocket specification. Socket should not be terminated prior to sending / receiving CLOSE
frame.
I suggest to double-check which frames are actually being sent and received. And double-check current Exasol version vs older versions.
In my view, the best approach would be to remove the necessity to send explicit disconnect
command and simplify things overall.
Sending CLOSE
frame from client should be equal to disconnect
. Client timing out on ping / pong frames should be equal to disconnect
.
If server wants to terminate a process, it should send CLOSE
frame to client properly. If it is not possible, and server process was terminated by SIGKILL, the client might see a random error message like this, but it should be a very rare occurrence.
@littleK0i, thank you for all the insights; they have been very helpful, and I also agree with many of the points you made. Regarding the potential change in the WebSocket protocol requirement, I'm not certain if I can directly impact or influence that modification, despite acknowledging its beauty. I plan to set aside some time at the end of the month to thoroughly examine the lower layers of the WebSocket client library and see if the issue can be identified and addressed there.
I appreciate your feedback, thanks.
Summary
The WebSocket connection isn't properly closed using the disconnect command at the Exasol WebSocket protocol level when a process is terminated.
Reproducing the Issue
Expected Behaviour
Actual Behaviour
Root Cause (optional)