J'utilise la bibliothèque P4Java dans mon fichier build.gradle pour synchroniser un gros fichier zip (> 200MB) résidant dans un dépôt Perforce distant, mais je rencontre un "java.net" Erreur ".socketTimeoutException: lecture expirée" au cours du processus de synchronisation ou (principalement) lors de la suppression du client temporaire créé pour l'opération de synchronisation. Je fais référence http://razgulyaev.blogspot.in/2011/08/p4-java-api-how-to-work-with-temporary.html pour travailler avec des clients temporaires en utilisant l'API P4Java.Gradle P4Java java.net.SocketTimeoutException: J'ai dépassé le délai
J'ai essayé d'augmenter le délai d'attente de lecture du socket par défaut de 30 secondes comme suggéré dans http://answers.perforce.com/articles/KB/8044 et également en introduisant le sommeil, mais les deux approches n'ont pas résolu le problème. Si vous tentez de vérifier la connexion à l'aide de getServerInfo() juste avant d'effectuer des opérations de synchronisation ou de suppression, le serveur vérifie la connexion. Quelqu'un peut-il me dire où je devrais chercher des réponses?
Merci.
Fournir l'extrait de code:
void perforceSync(String srcPath, String destPath, String server) {
// Generating the file(s) to sync-up
String[] pathUnderDepot = [
srcPath + "*"
]
// Increasing timeout from default 30 sec to 60 sec
Properties defaultProps = new Properties()
defaultProps.put(PropertyDefs.PROG_NAME_KEY, "CustomBuildApp")
defaultProps.put(PropertyDefs.PROG_VERSION_KEY, "tv_1.0")
defaultProps.put(RpcPropertyDefs.RPC_SOCKET_SO_TIMEOUT_NICK, "60000")
// Instantiating the server
IOptionsServer p4Server = ServerFactory.getOptionsServer("p4java://" + server, defaultProps)
p4Server.connect()
// Authorizing
p4Server.setUserName("perforceUserName")
p4Server.login("perforcePassword")
// Just check if connected successfully
IServerInfo serverInfo = p4Server.getServerInfo()
println 'Server info: ' + serverInfo.getServerLicense()
// Creating new client
IClient tempClient = new Client()
// Setting up the name and the root folder
tempClient.setName("tempClient" + UUID.randomUUID().toString().replace("-", ""))
tempClient.setRoot(destPath)
tempClient.setServer(p4Server)
// Setting the client as the current one for the server
p4Server.setCurrentClient(tempClient)
// Creating Client View entry
ClientViewMapping tempMappingEntry = new ClientViewMapping()
// Setting up the mapping properties
tempMappingEntry.setLeft(srcPath + "...")
tempMappingEntry.setRight("//" + tempClient.getName() + "/...")
tempMappingEntry.setType(EntryType.INCLUDE)
// Creating Client view
ClientView tempClientView = new ClientView()
// Attaching client view entry to client view
tempClientView.addEntry(tempMappingEntry)
tempClient.setClientView(tempClientView)
// Registering the new client on the server
println p4Server.createClient(tempClient)
// Surrounding the underlying block with try as we want some action
// (namely client removing) to be performed in any way
try {
// Forming the FileSpec collection to be synced-up
List<IFileSpec> fileSpecsSet = FileSpecBuilder.makeFileSpecList(pathUnderDepot)
// Syncing up the client
println "Syncing..."
tempClient.sync(FileSpecBuilder.getValidFileSpecs(fileSpecsSet), true, false, false, false)
}
catch (Exception e) {
println "Sync failed. Trying again..."
sleep(60 * 1000)
tempClient.sync(FileSpecBuilder.getValidFileSpecs(fileSpecsSet), true, false, false, false)
}
finally {
println "Done syncing."
try {
p4Server.connect()
IServerInfo serverInfo2 = p4Server.getServerInfo()
println '\nServer info: ' + serverInfo2.getServerLicense()
// Removing the temporary client from the server
println p4Server.deleteClient(tempClient.getName(), false)
}
catch(Exception e) {
println 'Ignoring exception caught while deleting tempClient!'
/*sleep(60 * 1000)
p4Server.connect()
IServerInfo serverInfo3 = p4Server.getServerInfo()
println '\nServer info: ' + serverInfo3.getServerLicense()
sleep(60 * 1000)
println p4Server.deleteClient(tempClient.getName(), false)*/
}
}
}
Une chose inhabituelle que j'ai observé pendant la suppression tempClient était-il supprimait effectivement le client, mais en jetant encore « java.net.SocketTimeoutException: Read timed out » qui est pourquoi je a fini par commenter la deuxième tentative d'effacement dans le second bloc catch.
Pouvez-vous montrer du code? – JimiLoe
@JimiLoe Pouvez-vous s'il vous plaît jeter un oeil sur le code? –