Work over unreliable networks
Limit network waiting time
To set a hard limit on the number of seconds a connection waits on any single network read or write before disconnecting with a network error:
-
add a line for
net.maxwait
value in the client's P4CONFIG file. For example,net.maxwait=60
or
-
use
-vnet.maxwait=
on a per-command basis, wheret
t
is the number of seconds to wait before timing out. For example,p4 -vnet.maxwait=60 submit -c changenum
We recommend that you do NOT set net.maxwait
on the
Helix Core Server because it can cause commands to time out unnecessarily. For example, if
net.maxwait
is set to 60
on the server, users
of the Command-Line Client must complete every interactive form within
60 seconds.
Reconnection attempts
It is useful to combine net.maxwait
with the
-rN
global option, where N
is the number
of times to attempt reconnection if the network times out.
For example:
$ p4 -r3 -vnet.maxwait=60 sync
attempts to resume an interrupted sync up to three times before failing.
Avoid -r when reading from standard input
Avoid the use of
-r
on any command that reads from standard input, such as
$ find . -print | p4 -x - -r3 add
If such a command times out and is restarted, the result could be a filename that is incomplete.
A safer approach
If you are adding a large number of files over an unreliable connection, consider a file by file approach:
$ find directoryname -type f -exec p4 -r5 -vnet.maxwait=60 add {} \;
This finds all the files (-type f
) in directoryname
, and adds each one by invoking "p4
-r5 -vnet.maxwait=60 add
" for each file individually.
After all files have been added, assign the changelist a changelist number with p4 change, and submit the numbered changelist atomically with
$ p4 -r5 -vnet.maxwait=60 submit -c changenum
If connectivity is interrupted, the -r
value causes the submission to resume.