Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AuthenticationData from Floating License

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support
View previous topic :: View next topic  
Author Message
Kushal



Joined: 11 May 2018
Posts: 28

PostPosted: Thu Sep 26, 2019 7:53 am    Post subject: AuthenticationData from Floating License Reply with quote

Hi there,
I'm confused on how to get the AuthenticationData from Floating Lics, please help!

My Local License Code:
Code:
  Private Function LoadLocalLicense() As Boolean
        If _localLicense Is Nothing Then
            _localLicense = _localLicenseProvider.GetLicense()
        End If
        If _localLicense IsNot Nothing Then 'Custom Code
            Dim input As String = _localLicense.AuthenticationData
            If input IsNot Nothing Then
                Try
                    Dim element As Xml.Linq.XElement = Xml.Linq.XElement.Parse(input)
                    If element.Element("LicenseType") IsNot Nothing Then _License_Type = element.Element("LicenseType").Value.ToString.ToUpper
                    If element.Element("IsLimited") IsNot Nothing Then _License_IsLimited = CBool(element.Element("IsLimited").Value.ToString.ToUpper) '(Limited=Lifetime license but limited support)
                    If element.Element("CompanyName") IsNot Nothing Then MyCompany.CompanyName = element.Element("CompanyName").Value.ToString.ToUpper

                    If _License_Type = "LIFETIME" Then Return True

                Catch ex As Exception
                End Try
            End If
        End If
        Return _localLicenseProvider.IsValid(_localLicense)
    End Function


My Floating code: How do I access the AuthenticationData here?
Code:

Private Function LoadFloatingLicense() As Boolean
        If _floatingLicense Is Nothing AndAlso Not String.IsNullOrEmpty(UseFloatingLicense) Then
            _floatingLicense = GetFloatingLicense(LicenseServerAddress, LicenseServerPort)
            If _floatingLicense IsNot Nothing Then
                StartFloatingLicenseTimer()
            End If
        End If

        Return _floatingLicense IsNot Nothing
    End Function
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 4952

PostPosted: Thu Sep 26, 2019 11:16 pm    Post subject: Reply with quote

In the sample Floating License sample project the floating license does not include the AuthenticationData. You can easily modify the FloatingLicense class code to add AuthenticationData as a property and pass it to the FloatingLicense constructor when it is created in GetLicense eg

Code:
       public FloatingLicense GetLicense(string client)
        {
            FloatingLicense result = null;
            lock (this)
            {
                // check for an existing license first
                //
                foreach (FloatingLicense license in _activeLicenses)
                {
                    if (license.Client == client)
                    {
                        result = license;
                        break;
                    }
                }

                // otherwise create a new license if the limit has
                // not been exceeded
                //
                if (result == null)
                {
                    int numLicenses = NumFloatingLicenses;
                    if (_activeLicenses.Count >= numLicenses)
                        throw new LicenseLimitException(numLicenses);

                    result = new FloatingLicense(client, _license.AuthenticationData);
                    _activeLicenses.Add(result);
                }
            }
            return result;
        }

_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Kushal



Joined: 11 May 2018
Posts: 28

PostPosted: Mon Sep 30, 2019 11:12 am    Post subject: Reply with quote

The function that calls GetLicense as you advised is below:
Code:
Private Function GetFloatingLicense(ByVal serverAddress As String, ByVal serverPort As Integer) As FloatingLicense
            Dim result As FloatingLicense = Nothing
            While result Is Nothing
                Dim errorMsg As String = Nothing
                Try
                    Dim url As String = [String].Format("tcp://{0}:{1}/LicenseServer", serverAddress, serverPort)
                    Dim licenseServer As LicenseServer = TryCast(Activator.GetObject(GetType(LicenseServer), url), LicenseServer)
                    result = licenseServer.GetLicense(Environment.MachineName)
                Catch e As LicenseLimitException
                    errorMsg = String.Format(My.Resources.LicenseLimitMsg, e.Limit)
                Catch e As Exception
                    errorMsg = String.Format(My.Resources.LicenseServerErrorMsg, e.Message, serverAddress)
                End Try
                If errorMsg IsNot Nothing Then
                    Dim dr As DialogResult = MessageBox.Show(errorMsg, My.Resources.LicenseErrorTitle, MessageBoxButtons.RetryCancel, MessageBoxIcon.[Error])
                    If dr = DialogResult.Cancel Then
                        Exit While
                    End If
                End If
            End While
            Return result
        End Function


However, when debugging, even stepping through, I simply cannot get INTO GetLicense()!
Removed the SyncLock as well, but no change.
Any suggestions?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 4952

PostPosted: Mon Sep 30, 2019 11:56 pm    Post subject: Reply with quote

Just to clarify you are debugging your GetFloatingLicense method below but you are unable to step into the GetLicense method?

That is to be expected because the GetLicense method is not executing in this process - it executes in your server process. To debug this method you need to open another instance of Visual Studio with the SampleLicenseService project and in the Debug start options set the command line options to be:

/r

This enables you to run the service from the command line or within the debugger. You can start the project and set a break point in the GetLicense method which will be hit when the FloatingLicense application calls it.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Kushal



Joined: 11 May 2018
Posts: 28

PostPosted: Fri Oct 04, 2019 8:28 am    Post subject: Reply with quote

Ahhhh!!!
Thanks! That should've been obvious!!

Managed to add the Auth Data, cheers!
Back to top
View user's profile Send private message
Kushal



Joined: 11 May 2018
Posts: 28

PostPosted: Sat Oct 19, 2019 7:45 am    Post subject: Reply with quote

Hello there.
A new issue on the result data from the AuthData I'm getting from the license server;
Code:
Dim url As String = [String].Format("tcp://{0}:{1}/LicenseServer", serverAddress, serverPort)
                Dim licenseServer As LicenseServer = TryCast(Activator.GetObject(GetType(LicenseServer), url), LicenseServer)
                result = licenseServer.GetLicense(Environment.MachineName)


Error on, which takes about 30 seconds to move onto;
Code:
_License_ExpiryDate = result.expiryDate


Error:
Code:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 172.17.161.17:19399


Please note that the serverAddress passed, and the result which came back fine, uses 192.168.0.X
HOWEVER, this runs perfectly smoothly when stepping through during a debug session (the /r function in debug).
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 4952

PostPosted: Sun Oct 20, 2019 3:40 am    Post subject: Reply with quote

Are you entering the raw IP address for the server in the client software ie 192.168.0.X?

If this is the case I have no idea where the 172.17.161.17 address could be coming from. If you are entering the name of the computer and then you may have DNS issues on your network causing it to resolve to the wrong IP address.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group