Skip to content

Commit

Permalink
Specify timeout in msec instead of sec
Browse files Browse the repository at this point in the history
  • Loading branch information
r-brown committed Dec 2, 2021
1 parent ac424a1 commit d4aeec6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions NetLicensingClient/LicenseeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static ValidationResult validate(Context context, String number, String p
/// In the case of multiple product modules validation, required parameters indexes will be added automatically.
/// See NetLicensingAPI for details: https://netlicensing.io/wiki/licensee-services#validate-licensee
/// </summary>
public static ValidationResult validate(Context context, String number, ValidationParameters validationParameters, int timeoutInSeconds = 100)
public static ValidationResult validate(Context context, String number, ValidationParameters validationParameters, int timeoutInMilliseconds = 100000)
{
Dictionary<String, String> parameters = new Dictionary<String, String> ();
if (!String.IsNullOrEmpty(validationParameters.getProductNumber()))
Expand Down Expand Up @@ -128,7 +128,7 @@ public static ValidationResult validate(Context context, String number, Validati
pmIndex++;
}

netlicensing output = NetLicensingAPI.request(context, NetLicensingAPI.Method.POST, Constants.Licensee.ENDPOINT_PATH + "/" + number + "/" + Constants.Licensee.ENDPOINT_PATH_VALIDATE, parameters, timeoutInSeconds);
netlicensing output = NetLicensingAPI.request(context, NetLicensingAPI.Method.POST, Constants.Licensee.ENDPOINT_PATH + "/" + number + "/" + Constants.Licensee.ENDPOINT_PATH_VALIDATE, parameters, timeoutInMilliseconds);
return new ValidationResult (output);
}

Expand Down
2 changes: 1 addition & 1 deletion NetLicensingClient/NetLicensingClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ReleaseVersion>2.x</ReleaseVersion>
<PackOnBuild>true</PackOnBuild>
<PackageId>NetLicensingClient-csharp</PackageId>
<PackageVersion>2.5.0</PackageVersion>
<PackageVersion>2.5.1</PackageVersion>
<Authors>Labs64 NetLicensing</Authors>
<Copyright>© 2010 Labs64 GmbH</Copyright>
<PackageIconUrl>https://netlicensing.io/img/labs64-avatar-200x200.png</PackageIconUrl>
Expand Down
10 changes: 6 additions & 4 deletions NetLicensingClient/RestController/NetLicensingAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ class NetLicensingAPI
{
public enum Method { GET, POST, DELETE };

public static netlicensing request(Context context, Method method, String path, Dictionary<String, String> parameters, int timeoutInSeconds = 100)
public static netlicensing request(Context context, Method method, String path, Dictionary<String, String> parameters, int timeoutInMilliseconds = 100000)
{
if (timeoutInSeconds <= 0 || timeoutInSeconds > 300)
throw new NetLicensingException($"Illegal timeout value: {timeoutInSeconds}");
if (timeoutInMilliseconds <= 0)
{
throw new NetLicensingException($"Illegal timeout value: {timeoutInMilliseconds}");
}

#region HTTP request preparation
// Workaround of the mod_proxy_ajp problem.
Expand Down Expand Up @@ -101,7 +103,7 @@ public static netlicensing request(Context context, Method method, String path,
request.PreAuthenticate = true;
request.Accept = "application/xml";
request.SendChunked = false;
request.Timeout = timeoutInSeconds * 1000;
request.Timeout = timeoutInMilliseconds;
if (requestBody != null)
{
byte[] byteArray = Encoding.UTF8.GetBytes(requestBody);
Expand Down

0 comments on commit d4aeec6

Please sign in to comment.