[en] Events Exception (solved)

Topics: Technical Support
Jun 16, 2013 at 6:27 AM
Edited Jun 16, 2013 at 6:27 AM
Hey,

in the documentation of zyan I found following hint:
If server fails to invoke client's event handler, subscription is cancelled, and client's event handler is removed.
Now I ask: How I can determin that the subscription is cancelled? For our application is important that the clients still react of the event (refresh a list of data from dataserver). In our test app we have sometimes that the event not fireing anymore. But we can not notice why.

Have zyan a "Event is cancelled"-Event? (Server or client side)? What is needed to reactivate the event?

Thanks for your support
Coordinator
Jun 16, 2013 at 10:48 PM
Edited Jun 17, 2013 at 9:33 AM
Hi,
 
If server fails to invoke client's event handler, subscription
is cancelled, and client's event handler is removed.
Yes, that's true. Client event handlers are pure one-way calls.
They should never ever return values or throw exceptions.
The one and only valid situation where invoking the client event handler
might result in an exception is when the connection is broken unexpectedly
(due to network failure, client shutdown, etc). In this case the server assumes
that the client is not active anymore and cancels its subscription.
 
Now I ask: How I can determin that the subscription is cancelled?
I don't think that there is any way to check this in the current version of Zyan.
 
For our application is important that the clients still react of
the event (refresh a list of data from dataserver). In our test app
we have sometimes that the event not fireing anymore. But we can not notice why.
Are you sure that your event handlers can't leak uncaught exceptions?
Looks like this should be the reason why subscriptions are cancelled.
Event handlers work pretty stable, and even when the server is restarted,
all subscriptions are restored when the client re-establishes the connection.
 
Have zyan a "Event is cancelled"-Event? (Server or client side)?
No, current version doesn't have such an event.
I'll consider adding a server-side event so you can trace down this situation.
 
What is needed to reactivate the event?
I think that the only way to reactivate it is to subscribe again.
Coordinator
Jun 17, 2013 at 11:21 AM
Have zyan a "Event is cancelled"-Event? (Server or client side)?
I've added three events to ZyanComponentHost:
  • SubscriptionAdded — when a client subscribes to an event (+=)
  • SubscriptionRemoved — when a client unsubscribes from an event (-=)
  • SubscriptionCanceled — when a server cancels the subscription due to an exception.
Usage example:
AddHandler _ZyanHost.SubscriptionCanceled, AddressOf ZyanHost_SubscriptionCanceled
...

Private Sub ZyanHost_SubscriptionCanceled(Sender As Object, E As SubscriptionEventArgs)
    Console.WriteLine("Warning! Subscription to {0}.{1} is canceled due to the exception: {2}", _
         E.ComponentType, E.DelegateMemberName, E.Exception)
End Sub
Also, I've added extra protection to the client event handlers.
Exceptions thrown by client event handlers are not propagated to the server anymore,
so the server can be sure that if it caught an exception, then it must be connection problems.
This behavior however can be disabled for compatibility reasons using the
ZyanSettings.LegacyUnprotectedEventHandlers property.
Coordinator
Jun 17, 2013 at 11:22 AM
Please download the latest Zyan source code.
Let me know if it helps.
Jun 18, 2013 at 5:07 PM
Edited Jun 18, 2013 at 5:07 PM
Thank you yallie for your fast response and support.

I have tried the new version and the new Events are helpfull to find out some points of interest

If I use it in the local network then it works fine. But I want to try via Internet and VPN and then the events didn´t raised on client.

so I read your codeplex and find: Use TcpDuplex - and wow: I have change it and I think it works!!!!!

Thank you again for your great work an this tool - it save´s me much of time to implement a stable Client-Server Application with realtime Events

Wish you a fine day

CU
Michael

BTW: You mentioned a Version 2.5 of zyan. What are the improvments?
Coordinator
Jun 19, 2013 at 10:55 AM
so I read your codeplex and find: Use TcpDuplex - and wow: I have change it and I think it works!!!!!
Glad to hear that!
Duplex channel was specifically designed to address that exact problem.
 
it save´s me much of time to implement a stable Client-Server Application with realtime Events
Would you mind posting a short summary of your client-server application?
It's very important for Zyan users to know what kind of projects can be built with it.
We have a topic on this forum where we'd like to announce applications powered with Zyan.
Thanks in advance!
 
BTW: You mentioned a Version 2.5 of zyan. What are the improvments?
  • Android platform support.
  • Lots of improvements in event handling (restoring event handlers after server restart or reconnection).
  • Coutless bugfixes.
But if you build Zyan from the latest SVN sources, you already have Zyan 2.5 preview, effectively.

Regards, yallie.