Click here to Skip to main content
15,888,322 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello, i am trying to publish data to Redis as written code below, but don't know why i didn't get data to client side..

As even i am getting data to client when i am Publishing data with same channel-name from CLI or Command window in Redis Desktop Manager..
PUBLISH "{\"type\": 1, \"room\": \"1.111\"}" "{\"action\":2,\"body\":{\"test\":4444}}"
this is working well and getting data in clientside also..
Can anyone please help me is there any wrong in my c# code.. please help me out from this simple issue..

What I have tried:

C#
long cnt = -1;
try
{
    var chan = JsonConvert.SerializeObject(new { type = 1, room = "1.111" });
    var data = JsonConvert.SerializeObject(new { action = 2, body = new { date = DateTime.Now.ToString() } });
    ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(new ConfigurationOptions
    {
        AbortOnConnectFail = false,
        EndPoints = { "localhost" }
    });
    if (redis.IsConnected)
    {
        var sub = redis.GetSubscriber();
        cnt = sub.Publish(chan, data);
    }
}
catch (Exception ex)
{
//In exception, i am not getting any exception.. even getting response "1" in cnt variable..
}
Posted
Updated 27-Feb-20 22:54pm
v2

1 solution

C#
catch (Exception ex)
{}

That is not going to help you. If an exception occurs you are just ignoring it. At the very least you should show the actual details from the caught exception.
 
Share this answer
 
Comments
Kiran Patel 28-Feb-20 8:28am    
In exception, i am not getting any exception.. even getting response "1" in cnt variable..
Richard MacCutchan 28-Feb-20 8:54am    
Then you need to run your code in the debugger to find out what is happening. It is impossible for anyone else to guess.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900