How to do health check for a subscriber?

瀏覽次數:39 次
跳到第一則未讀訊息

Bruce Liu

未讀,
2013年4月15日 晚上11:32:242013/4/15
收件者:web...@googlegroups.com
Hi,
    We have one problem in our production environment. We have one publisher who publishs message to another server, and some subscribers, one of the subscriber is a website(site1) with javascript subscriber, which display the message from the websync server. the other is a windows service and which get the message and do some calculation and push to another website(site2) via some flash push technology. Now the problem is that sometimes we found the message in the site1 is different from the site2, and the developer of site2 always complain the message was lost from the websync server before they provided any concrete log to prove it.
Now my question is how can I check the window service subscriber is alive or not? From the websync server, can I check who are my alive clients at any time?
Just now we tried to use the [WebSyncEvent(EventType.BeforeSubscribe)] event, it was only fired when the subscriber subscribed the channel at the first time.
what I want is the real time status of the subscriber for each message delivery.


Thanks.
Bruce

Anton Venema

未讀,
2013年4月16日 凌晨1:03:542013/4/16
收件者:web...@googlegroups.com
Hi Bruce,

You're probably looking for the WebSyncServer class. It has a number of static methods that let you query for information about the current state of the WebSync server.

WebSyncServer.GetSubscribedClients should give you what you are looking for.


Anton Venema
Frozen Mountain Software
604-227-2458 (Canada)
919-300-5520 (United States)
888-379-6686 (Extension 
102)
www.frozenmountain.com




Bruce

--
You received this message because you are subscribed to the Google Groups "WebSync" group.
To unsubscribe from this group and stop receiving emails from it, send an email to websync+u...@googlegroups.com.
To post to this group, send email to web...@googlegroups.com.
Visit this group at http://groups.google.com/group/websync?hl=en.
To view this discussion on the web visit https://groups.google.com/d/msg/websync/-/2Zwn6Bkwt4gJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Bruce Liu

未讀,
2013年4月16日 清晨7:18:192013/4/16
收件者:web...@googlegroups.com
HI Anton Venema,
    Thanks for the information,
But it seems my domain key was wrong.
clients: f708da78-2535-46a0-9ed7-a1a200b7acd0 11111111-1111-1111-1111-111111111111
Here is my code:
 logger.Info("clients: " + string.Join(",", clients.Select(c => c.ClientId + " " + c.DomainKey)));
My colleague said it is because I am not using the licensed binaries, but we already bought websync for about one year.

by the way, will the domain key and client id be changed after the websync server restart?


Thanks.
Bruce

Anton Venema

未讀,
2013年4月16日 下午4:55:052013/4/16
收件者:web...@googlegroups.com
Hi Bruce,

The domain key defaults to all 1's. It doesn't have anything to do with licensing - it's a way for you to sandbox clients if that's a requirement for your project.

To answer your question, clients will always get a new ID when the WebSync server restarts. The domain key stays the same.

Anton Venema
Frozen Mountain Software
604-227-2458 (Canada)
919-300-5520 (United States)
888-379-6686 (Extension 
102)
www.frozenmountain.com



To view this discussion on the web visit https://groups.google.com/d/msg/websync/-/M0mczhhJi5sJ.

Bruce Liu

未讀,
2013年4月16日 晚上7:45:132013/4/16
收件者:web...@googlegroups.com、web...@googlegroups.com
Hi Anton,
    Thanks for clarification. So are there any way to get client IP from Getsubscribedclients() method or any other attribute so that we can identify the client even it's clientid was changed? We have to restart the server because we change something in the server's web.config file at that time.

Thanks,
Bruce
You received this message because you are subscribed to a topic in the Google Groups "WebSync" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/websync/jO5xnWpf8QY/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to websync+u...@googlegroups.com.

To post to this group, send email to web...@googlegroups.com.
Visit this group at http://groups.google.com/group/websync?hl=en.

Anton Venema

未讀,
2013年4月16日 晚上7:58:372013/4/16
收件者:web...@googlegroups.com
Hi Bruce,

Definitely!

WebSync allows you to bind custom data to a client (IP address, username, etc.). Simply call client.Bind(...) with the key/value you want to store. That bound data is persisted to the server so it is accessible wherever the client record is found.

Check out the "Binding" section of our Getting Started guide:


Anton Venema
Frozen Mountain Software
604-227-2458 (Canada)
919-300-5520 (United States)
888-379-6686 (Extension 
102)
www.frozenmountain.com



Bruce Liu

未讀,
2013年4月16日 晚上10:24:242013/4/16
收件者:web...@googlegroups.com
HI Anton,
    Thanks for the information.
It seems I need to change the window service client code? But I has no control on it, it was done by another team.
Can I do the binding in the server side?

Thanks.
Bruce

Anton Venema

未讀,
2013年4月17日 上午11:16:212013/4/17
收件者:web...@googlegroups.com
Absolutely.

You can "force-bind" a client from any of the server-side events. The most logical place to do this would be in the AfterConnect event. We even have a code snippet in our documentation that shows you exactly how:


Anton Venema
Frozen Mountain Software
604-227-2458 (Canada)
919-300-5520 (United States)
888-379-6686 (Extension 
102)
www.frozenmountain.com



To view this discussion on the web visit https://groups.google.com/d/msg/websync/-/ZO5Xpv0dK8MJ.

Bruce Liu

未讀,
2013年4月17日 晚上11:35:342013/4/17
收件者:web...@googlegroups.com
HI Anton,
    thanks for the information,
After we tried the AfterConnect() event in server side, we found all subscriber can't receive any message any more.

Here is our code. Do we need to call some method in WebSyncEventArgs to accept the connection?

        [WebSyncEvent(EventType.AfterConnect)]
        public static void BindIP(object sender, WebSyncEventArgs e)
        {
            var context = (e.Context.OriginalContext as HttpContextWrapper);
            if (context != null)
            {
                var ip =
                    (context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ??
                     context.Request.ServerVariables["REMOTE_ADDR"]).Split(',')[0].Trim();

                    logger.Info("Bind LAN IP: " + ip + " " + e.ClientId);
                    e.Client.Bind("ClientIP", ip);
            }
            else
            {
                logger.Error("Context is null");
            }
        }

Thanks.
Bruce

Anton Venema

未讀,
2013年4月18日 凌晨1:26:262013/4/18
收件者:web...@googlegroups.com
The value must be valid JSON (the parameter name is valueJson). Try serializing the IP to JSON before binding it:

e.Client.Bind("ClientIP", Json.Serialize(ip));
To view this discussion on the web visit https://groups.google.com/d/msg/websync/-/ZO5Xpv0dK8MJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "WebSync" group.
To unsubscribe from this group and stop receiving emails from it, send an email to websync+u...@googlegroups.com.
To post to this group, send email to web...@googlegroups.com.
Visit this group at http://groups.google.com/group/websync?hl=en.
To view this discussion on the web visit https://groups.google.com/d/msg/websync/-/tGNGlGtuMMkJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 


--

Bruce Liu

未讀,
2013年4月18日 清晨7:49:382013/4/18
收件者:web...@googlegroups.com
Hi Anton,
    It works perfectly!
Thanks, You are so helpful that you always can provide perfect solutions to ALL my problems.

Thanks a lot.
Bruce
To unsubscribe from this group and stop receiving emails from it, send an email to websync+unsubscribe@googlegroups.com.

To post to this group, send email to web...@googlegroups.com.
Visit this group at http://groups.google.com/group/websync?hl=en.
To view this discussion on the web visit https://groups.google.com/d/msg/websync/-/tGNGlGtuMMkJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jerod Venema

未讀,
2013年4月18日 上午8:38:322013/4/18
收件者:web...@googlegroups.com
P.S., you should wrap your code in your event handlers in try...catch blocks, and log any errors; either that or handle the onFailure methods on the client side and alert the error there. Any errors will be thrown to the client in the appropriate onFailure event on the client side unless you handle them yourself!

Best,

To unsubscribe from this group and stop receiving emails from it, send an email to websync+u...@googlegroups.com.

To post to this group, send email to web...@googlegroups.com.
Visit this group at http://groups.google.com/group/websync?hl=en.
To view this discussion on the web visit https://groups.google.com/d/msg/websync/-/dcAFuL1LnNEJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Jerod Venema
Frozen Mountain Software
919-300-5141 (United States)
604-227-2453 (Canada)
888-379-6686 (Extension 101)

Bruce Liu

未讀,
2013年4月18日 上午9:02:492013/4/18
收件者:web...@googlegroups.com、web...@googlegroups.com
Hi Anton,
    Good idea. We will implement that later.
    Thanks.

Best Regards,
Bruce
You received this message because you are subscribed to a topic in the Google Groups "WebSync" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/websync/jO5xnWpf8QY/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to websync+u...@googlegroups.com.

To post to this group, send email to web...@googlegroups.com.
Visit this group at http://groups.google.com/group/websync?hl=en.
回覆所有人
回覆作者
轉寄
0 則新訊息