reducing application inactivity timeout to make contollers happier
This commit is contained in:
parent
469ba453c1
commit
6de35bf264
|
@ -5,6 +5,7 @@ package com.rusefi;
|
|||
*/
|
||||
public interface Timeouts {
|
||||
int SECOND = 1000;
|
||||
int MINUTE = 60 * SECOND;
|
||||
int COMMAND_TIMEOUT_SEC = 10; // seconds
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,8 +21,9 @@ public class BinaryProtocolProxy {
|
|||
/**
|
||||
* we expect server to at least request output channels once in a while
|
||||
* it could be a while between user connecting authenticator and actually connecting application to authenticator
|
||||
* See Backend#APPLICATION_INACTIVITY_TIMEOUT
|
||||
*/
|
||||
public static final int USER_IO_TIMEOUT = 600 * Timeouts.SECOND;
|
||||
public static final int USER_IO_TIMEOUT = 10 * Timeouts.MINUTE;
|
||||
|
||||
public static ServerHolder createProxy(IoStream targetEcuSocket, int serverProxyPort) {
|
||||
Function<Socket, Runnable> clientSocketRunnableFactory = clientSocket -> () -> {
|
||||
|
|
|
@ -24,12 +24,9 @@ public class NetworkConnectorStartup {
|
|||
return;
|
||||
}
|
||||
|
||||
SessionDetails sessionDetails = NetworkConnector.runNetworkConnector(authToken, autoDetectedPort, Backend.SERVER_PORT_FOR_CONTROLLERS, new TcpIoStream.DisconnectListener() {
|
||||
@Override
|
||||
public void onDisconnect() {
|
||||
System.err.println("Disconnect detected");
|
||||
System.exit(-1);
|
||||
}
|
||||
SessionDetails sessionDetails = NetworkConnector.runNetworkConnector(authToken, autoDetectedPort, Backend.SERVER_PORT_FOR_CONTROLLERS, () -> {
|
||||
System.err.println("Disconnect detected");
|
||||
System.exit(-1);
|
||||
});
|
||||
System.out.println("Running with " + sessionDetails.getOneTimeToken());
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
/**
|
||||
* Connector between rusEFI ECU and rusEFI server
|
||||
* see NetworkConnectorStartup
|
||||
*/
|
||||
public class NetworkConnector {
|
||||
public static SessionDetails runNetworkConnector(String authToken, String controllerPort, int serverPortForControllers, TcpIoStream.DisconnectListener disconnectListener) throws InterruptedException, IOException {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.rusefi.server;
|
|||
|
||||
import com.devexperts.logging.Logging;
|
||||
import com.rusefi.Listener;
|
||||
import com.rusefi.Timeouts;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.io.IoStream;
|
||||
|
@ -42,6 +43,14 @@ public class Backend implements Closeable {
|
|||
private static final String MAX_PACKET_GAP = "MAX_PACKET_GAP";
|
||||
private static final String IS_USED = "isUsed";
|
||||
|
||||
/**
|
||||
* Application with exclusive access should connect tuning application within 3 minutes
|
||||
* Should be at least twice less than USER_IO_TIMEOUT to prevent controller disconnect
|
||||
*
|
||||
* @see BinaryProtocolProxy#USER_IO_TIMEOUT
|
||||
*/
|
||||
private static final int APPLICATION_INACTIVITY_TIMEOUT = 3 * Timeouts.MINUTE;
|
||||
|
||||
private final FkRegex showOnlineControllers = new FkRegex(ProxyClient.LIST_CONTROLLERS_PATH,
|
||||
(Take) req -> getControllersOnline()
|
||||
);
|
||||
|
@ -69,7 +78,7 @@ public class Backend implements Closeable {
|
|||
public int serverPortForControllers;
|
||||
|
||||
public Backend(UserDetailsResolver userDetailsResolver, int httpPort) {
|
||||
this(userDetailsResolver, httpPort, 600 * SECOND);
|
||||
this(userDetailsResolver, httpPort, APPLICATION_INACTIVITY_TIMEOUT);
|
||||
}
|
||||
|
||||
public Backend(UserDetailsResolver userDetailsResolver, int httpPort, int applicationTimeout) {
|
||||
|
|
Loading…
Reference in New Issue