One may control the timeout using RequestTimeoutMs parameter value:

From the code the same may be done using

<object>.SetParameter('RequestTimeoutMs', <value>)

or

Session.SetParameter('RequestTimeoutMs', <value>)

Where Session call will set timeout for all subsequent rest calls using DoExecute, i.e.:

function Test(params)
{
    // Set timeout to 30 seconds
    Session.SetParameter('RequestTimeoutMs', 30000);
    var PetDocs_GetPetById=SeS('PetDocs_GetPetById');
    PetDocs_GetPetById.DoExecute();
}

g_load_libraries = ["Web Service"];