Android Question Error: Nonce must be greater than...

carlos7000

Active Member
Licensed User
Hello

I am using this function to send commands to a server

SendCommand:
private Sub SendCommand(workName As String, Command As String, Signature As Boolean, url as String)
    Dim ToSing As String
    
    If Signature Then
        url = X_PrivateUrl

        ToSing = "command=" & workName & "&" & Command & "&nonce=" & DateTime.Now
    
        Dim Sign() As Byte
        Sign = Functions.HashHmac(ToSing, Functions.GetSecret)
            
        Dim API_Signed As String
        Dim Byte_Conv As ByteConverter
        API_Signed = Byte_Conv.HexFromBytes(Sign) 'convert to HEX
        API_Signed = API_Signed.ToLowerCase
    Else
        url = url & "?command=" & workName & Command
    End If
        
    Dim j As HttpJob
        
    j.Initialize(workName, Me)
    j.PostBytes(url, ToSing.GetBytes("UTF8"))
    
    If (Signature == True)Then
        j.GetRequest.SetHeader("Key", Functions.GetKey)
        j.GetRequest.SetHeader("Sign", API_Signed)
        'j.GetRequest.SetHeader("nonce", nonce)
    End If
End Sub
When using the previous function, The server always answers something like that:

Nonce must be greater than 1577596982687 you provided 1577596982687
try to add or remove time to nonce as follows

AddTime:
Dim Now As Long
    Now = DateTime.Now + 50
    ToSing = "command=" & workName & "&" & Command & "&nonce=" & Now
or

AddTime:
Dim Now As Long
    Now = DateTime.Now - 50
    ToSing = "command=" & workName & "&" & Command & "&nonce=" & Now
No matter how much time you add or subtract. Always the time I send equal or less than required.

Thanks
 
Top