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
Goto page 1, 2  Next
 
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: 42

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: 4993

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: 42

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: 4993

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: 42

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: 42

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: 4993

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
Kushal



Joined: 11 May 2018
Posts: 42

PostPosted: Thu Jan 02, 2020 7:42 am    Post subject: Reply with quote

Happy New Year!!

Sorry for the delay in getting back onto this topic.
Managed to get things working and just ignored this issue for a while!

Ok, so my issue is reading the lic data; including number of floating, expiry date, AuthenticationData.

My code getting the result from .GetLicense is untouched, as shown below;
Code:

Dim errorMsg As String = Nothing
            Try
                Dim url As String = [String].Format("tcp://{0}:{1}/LicenseServer", serverAddress, serverPort)
                _logger.Info(url)
                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)
.........
.......
....


Result comes back fine, but when reading anything from result, i get the error previously mentioned, with a random (invalid) IP address;

ANY OF THE BELOW TYPE OF ATTEMPTS:
Debug.Print(result.expiryDate.ToString)

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


So finally,
what's the CORRECT way to get data from 'result'?

*I'm using BOTH floating and local licenses in my app.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 4993

PostPosted: Thu Jan 02, 2020 8:21 am    Post subject: Reply with quote

I think this has to be a network configuration (DNS lookup) issue. I can't see anyway that the code can generate random IP addresses. Try entering the raw IP address when configuring the client rather than a name which has to be resolved.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Kushal



Joined: 11 May 2018
Posts: 42

PostPosted: Thu Jan 02, 2020 9:33 am    Post subject: Reply with quote

We are using raw IP addresses to avoid any issues.
We've also tried to use static IP's between the client and server, but the same issue occurs.

Am I reading the result the right way?
Code:
_License_ExpiryDate = result.expiryDate
_License_AuthData = result.AuthData



In the LicenceService, I create the FloatingLicense like this;
Code:
 Friend Sub New(ByVal client As String, ByVal authdata As String, ByVal numOfLics As Integer, ByVal expirydate As Date)
        Me.Client = client
        Me.AuthData = authdata
        Me.numOfLics = numOfLics
        Me.expiryDate = expirydate
    End Sub


Above fields are from the same (Service project, FloatingLicense.vb)
Code:
    Public ReadOnly Property Client() As String
    Public ReadOnly Property AuthData() As String
    Public ReadOnly Property numOfLics() As Integer
    Public ReadOnly Property expiryDate() As Date
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 4993

PostPosted: Mon Jan 06, 2020 2:34 am    Post subject: Reply with quote

Is the IP address (172.17.161.17) in the error message the IP address of your server?

If you are using the raw IP address for the server when configuring the client and then you get an error message which has a different IP address in it then I don't see how this could possibly occur - other than some very strange networking configuration issue.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Kushal



Joined: 11 May 2018
Posts: 42

PostPosted: Mon Jan 06, 2020 6:06 am    Post subject: Reply with quote

Sorry, forgot to mentioned the customers IP.
They're running on 192.168.0.0/20
The computers were tested with static and DHCP IP's on the same sequence.

Client has about 20 PC's in the same office, 3 of them have this issue.
The IP in the error is either starting from 172 or 169, which ususally occur when DHCP fails.

The stack trace;

Code:
System.Net.Sockets.SocketException: 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 169.254.85.40:19399
at
at Server stack trace:
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket(EndPoint ipEndPoint)
at System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket()
at System.Runtime.Remoting.Channels.RemoteConnection.GetSocket()
at System.Runtime.Remoting.Channels.SocketCache.GetSocket(String machinePortAndSid, Boolean openNew)
at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.SendRequestWithRetry(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream)
at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)
at
at Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.Object.ToString()
at Raminian.Program.GetFloatingLicense(String serverAddress, Int32 serverPort)
at Raminian.Program.InstallFloatingLicense(String serverAddress, Int32 serverPort)
at Raminian.LicenseSelectForm.OnClosing(CancelEventArgs e)
at System.Windows.Forms.Form.CheckCloseDialog(Boolean closingOnly)


Again,
Am I reading the result the right way?
Code:
License_ExpiryDate = result.expiryDate
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 4993

PostPosted: Mon Jan 06, 2020 10:48 pm    Post subject: Reply with quote

If some clients are connecting and others not then it is definitely a networking configuration issue.

It still is not clear from your answers. Are you configuring the clients to connect by entering the server IP address?

If so what is the server address?

If the server address is not the same as the IP address being reported in the error message I don't really understand how that could happen - there must be some strange IP redirection going on on the PC/network.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Kushal



Joined: 11 May 2018
Posts: 42

PostPosted: Tue Jan 07, 2020 5:49 am    Post subject: Reply with quote

Server is 192.168.0.99, Subnet of 255.255.240.0
Client is on 192.168.0.66, Subnet of 255.255.240.0
Tried client on a different IP, both, static and dynamic.

AM I READING THE FLOATING LICENSE THE RIGHT WAY? BY USING RESULT.CUSTOM_FIELD?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 4993

PostPosted: Tue Jan 07, 2020 7:14 am    Post subject: Reply with quote

When you configured the client did you specify the server by IP address?

I have no idea what you mean by "result.custom_field".
_________________
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
Goto page 1, 2  Next
Page 1 of 2

 
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