[en] Longtime Server-Functions is called twice (solved)

Topics: Technical Support
Feb 18, 2014 at 4:01 PM
I have programming a sever-client application with Zyan as communication.

Now I have implement a longtime function. This runs on Server. If the sever send the result back, the same function will recursiv execute again

How can I find out the reason? I have trace the functions from Zyan but I don´t find the reason for that Problem

can you help me?
Coordinator
Feb 18, 2014 at 10:12 PM
Hi Michael,

Unfortunately, the information you've provided is not enough to guess where is the problem.
If you're certain that the issue is not in your code, please provide me the sample code.
I need to reproduce the problem to find the solution.

Do you, by any chance, use call interception for this long-running method?
If yes, make sure you're not missing the data.Intercepted = true; part in your interceptor. Example:
var interceptor = CallInterceptor.For<IInterceptableComponent>().Action<long, TimeSpan, short, IInterceptableComponent>(
    (component, arg1, arg2, arg3, arg4) => component.Procedure(arg1, arg2, arg3, arg4),
    (data, arg1, arg2, arg3, arg4) =>
    {
        if (arg1 == 123)
        {
            flag = true;
            data.Intercepted = true; // suppress the intercepted remote method call
        }
    });
For now, it looks to me like you simply call the method again from the client somehow.
I'd suggest that you try the following to investigate the issue:
— Grab the latest Zyan source and build it on your machine in Debug configuration to get PDB files;
— Attach Visual Studio debugger to the client process;
— Open ZyanProxy.cs in Visual Studio and set a breakpoint on InvokeRemoteMethod method;
— Wait for invocation of your long-running method (you can find method name in methodCallMessage properties);
— Compare call stacks of the first and second invocations of your method using Visual Studio Call stack window.
Chances are you'll find the code that calls your method for the second time.

Kind regards, Alex
Feb 19, 2014 at 8:15 AM
Ok - i will try to descripe the code:

Clientside:
        _ZyanProxy = ConnectClient.Connection.CreateProxy(Of IValuationsManagement)()

        _result = _ZyanProxy.CopyActiveArticlesToWorkTable(_Values.Date, _Values.InventureGuid.ToString)
        If _result.HasErrors = False Then
            _result = _ZyanProxy.CalculateValuation(Int(Right(_Values.TypeGuid.ToString, 2)), _Values.Guid.ToString)
        End If
Server-side:
   Public Function CalculateValuation(PriorityType As CommonEnums.InventureValuationPriorityTypes, ValuationGuid As String) As KmfFxXT.DataExtensions.DataSource.ServerResult Implements Common.Application.IValuationsManagement.CalculateValuation


       ' Logtime Code follows here
       .....



        Return _result

    End Function
I dind´t use a CallInceptor on Client or Sever now
Feb 19, 2014 at 10:17 AM
Edited Feb 19, 2014 at 10:38 AM
I found following things via Debugging the ZyanProxy.cs
  • The Command InvokeRmotemethod is only execute 1 time
  • The Server Method CopyActiveArticles...... run 1 time complete to end. The result will calculate.
  • After the first run I have a "green" SocketException: The Host is unknown
  • Then I can step through Zyan-Code only on serverside. And the CopyActiveArticle... starts again
  • After the second run of the method i have a CryptoRemotingException on Client-Side: The clientside channelsink cannot etablish a encrypted Connection to Server (I have translated from german)
  • I have reduce the longtime Function (Change "for each all" to "for next 1 to 10") and the result will send succesfull back
My Idea: This is a Timing Problem - I think the Server/Client Forget/Close the session/connection
Coordinator
Feb 20, 2014 at 3:10 PM
Hi Michael!
 
After the first run I have a "green" SocketException: The Host is unknown
 
Where do you get this exception? Server-side or client-side?
 
Then I can step through Zyan-Code only on serverside. And the CopyActiveArticle... starts again
 
What's displayed in the Call Stack window when the method is started again? What class initiates this second method invocation?
 
After the second run of the method i have a CryptoRemotingException on Client-Side:
The clientside channelsink cannot etablish a encrypted Connection to Server (I have translated from german)
 
That's strange... Crypto-channel sinks establish encrypted channel when the connection is first initiated. They don't try reconnecting at later stages. Have you got the call stack of this crypto-remoting-exception?
 
I have reduce the longtime Function (Change "for each all" to "for next 1 to 10") and the result will send succesfull back
 
I.e. when the finction execution time is considerably less, it executes without problems? How long it takes to execute the original function? And how long does the shorter version run?
 
My Idea: This is a Timing Problem - I think the Server/Client Forget/Close the session/connection
 
Don't quite understand what do you mean by that. The server and the client don't close sessions unless you dispose the ZyanConnection object explicitly. The only case when the open session can be dropped is when a client doesn't respond for the long period of time (i.e. when the connection is essentially lost). But that should be taken care of automatically with heartbeat events.

P.S. Have you managed to reproduce the issue in a small solution? If I had a reproducible example, I'd be able to find the issue much faster.
Feb 25, 2014 at 12:26 PM
Hey,

I break me head - it´s so complicate

I have create a small application to communicate via Zyan a very Long time (1h) but the function will execute 1time

My next try was make Unit-Test on Sever call - not reproducable

Next step was the Unit-Tests on Client-Side - same Problem with double execution
Feb 25, 2014 at 3:09 PM
Here are my last results:

The mentioned behavior is reproduceable if you use TcpEx with Transportencryption and Functions they run longer as some secondes
Coordinator
Feb 28, 2014 at 5:05 PM
Edited Mar 1, 2014 at 4:26 PM
Hi Michael!

The issue has been fixed. Thanks a lot for reporting it!
Please download the latest Zyan source code and build it yourself.
This fix will be included in the next release.
Marked as answer by yallie on 2/28/2014 at 9:06 AM
Coordinator
Mar 1, 2014 at 4:27 PM
Mar 7, 2014 at 3:41 PM
YES - It works now fine with my communication configuration

sorry, for my late Response - but very much "Thank you" to you for your work