0 votes
by (230 points)

Occasionally, we find that the SFTP Server may miss the Disconnect request from Client.

On client side, the Disconnect command ended normally without any exception and so was deemed successful. However, on the Server, there was no sign of any Disconnect request. As such, the session remain active and sometimes this un-closed session will keep locking up a half-uploaded file.

This happens more often when the client is using wifi to communicate with the server and it seems that corrupted data may be the root cause of the problem. However, do wish to know if there is anyway to solve this problem or at least to work-around with it.

Thanks in advance for your help.

1 Answer

0 votes
by (144k points)

This might occur when the connection is lost abruptly at the client side and the established TCP socket is left active but not operational.

To prevent this, detect such abandoned sockets and terminate the sessions, enable keep-alive detection at the server side:

var server = new FileServer();
server.Settings.KeepAlivePeriod = 30;
...

This instructs the server to send a short 'ignore' packet to the client each 30 seconds, which eventually triggers disconnect if the packet cannot be transmitted.

by (230 points)
Dear Lukas,

Thank you very much for your suggestion. It solves my problem !

Best Regards,
Stony Kong
...