Fail a download whose file server stops sending
The data socket had no read timeout, so a file server that went quiet left the transfer, and its thread, waiting until the user cancelled. Thirty seconds without data now fails it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -46,6 +46,8 @@ import java.util.function.Supplier;
|
|||||||
public final class FileTransferManager {
|
public final class FileTransferManager {
|
||||||
|
|
||||||
private static final int CONNECT_TIMEOUT_MS = 15_000;
|
private static final int CONNECT_TIMEOUT_MS = 15_000;
|
||||||
|
/** How long a download may go without receiving anything before it counts as failed. */
|
||||||
|
private static final int STALL_TIMEOUT_MS = 30_000;
|
||||||
private static final int BUFFER_SIZE = 64 * 1024;
|
private static final int BUFFER_SIZE = 64 * 1024;
|
||||||
/** How long to wait for the server's {@code notifystart*} reply after an {@code ftinit*}. */
|
/** How long to wait for the server's {@code notifystart*} reply after an {@code ftinit*}. */
|
||||||
private static final long NEGOTIATE_TIMEOUT_MS = 15_000;
|
private static final long NEGOTIATE_TIMEOUT_MS = 15_000;
|
||||||
@@ -406,6 +408,7 @@ public final class FileTransferManager {
|
|||||||
Socket socket = new Socket();
|
Socket socket = new Socket();
|
||||||
socket.connect(new InetSocketAddress(resolveHost(params.getFileServerHost()),
|
socket.connect(new InetSocketAddress(resolveHost(params.getFileServerHost()),
|
||||||
params.getFileServerPort()), CONNECT_TIMEOUT_MS);
|
params.getFileServerPort()), CONNECT_TIMEOUT_MS);
|
||||||
|
socket.setSoTimeout(STALL_TIMEOUT_MS);
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user