redis c# client, how do i get Subscribers count?

Doron Eli

i need to give statistic about my publisher app like how many subscribers are there?

i cant seen to get that information from the redis server

i already tried to find in the 'ServiceStack.Redis.RedisSubscription'

i found this:

        var channel = ConfigurationManager.AppSettings["redis_channel"];
        var _redisClient = new RedisClient("localhost", 6379);
        var subscription = _redisClient.CreateSubscription();
        //subscription.SubscribeToChannels(channel);
        var subscription_count = (int)subscription.SubscriptionCount

but it returning 0 every time.

any ideas?

edit: i found this http://redis.io/commands/client-list but steel need some help on how to use it thanks : )

Doron Eli

i got it!

if anyone need that's i did:

var redis_ip = ConfigurationManager.AppSettings["redis_server_ip"];
        var redis_port = ConfigurationManager.AppSettings["redis_server_port"];
        int redis_port_int = 0;
        if (!int.TryParse(redis_port, out redis_port_int))
        {
            redis_port_int = 6739;
        }
        RedisNativeClient rnClient = new RedisNativeClient(redis_ip, redis_port_int);
        var clientlist_byte = rnClient.ClientList();
        var clientlist_string = Encoding.UTF8.GetString(clientlist_byte);
        var clientamount_double = clientlist_string.Split("\n".ToCharArray()).Length;
        var clientlist_int = (clientamount_double/2) - 1;
        return clientlist_int;

the '-1' is to remove my selt from the count, the /2 it's because after the split i get a doubled amount

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do i get the redis store client from socket-io-redis?

How do I pause shareReplay when there are no subscribers

How do I estimate the number of RSS subscribers?

Redis: How do I count the elements in a stream in a certain range?

How do i get client ip with kubernetes?

How do I get the count of messages in the mailbox?

How do I get the row count in JDBC?

How do I get the count of a Swift enum?

How do I get the Git commit count?

How do i get count to work in this script

Rally C#: How do i get count of features under a release worked on by defined set of owners?

How to get client addr from redis?

How do I get the remote address of a client in WebRequest

How do I get the hostname of a connected client in java?

How do I Get the Client User's Last Message?

How do I get the MsalGuard to use my client ID?

how do i get client ip address in js

How do I get the client IP of a Tornado web socket request?

How do i get the client ip address on a python server

How do I get client IP and browser info in Blazor?

How do I get CID (Client ID) for the Expedia Affiliate Network?

How do I get the client id in a Laravel app?

How do I get the Swagger-generated Python client to work?

How do I render data from an HTTP GET on the client (with Handlebars)

How do I get Landscape to apply USNs to client?

How do i get the client secret in soundcloud api?

How do I count the number of submitted GET params?

How do I get the count in mongoDB through Spring Boot?

how do I get the count of rows in a appended/merged DataFrame in pandas?