StackExchange / StackExchange/StackExchange.Redis
suber is freeze.
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.2k
- Forks
- 1.6k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 43
Description
pub:
using System;
using StackExchange.Redis;
class Publisher
{
static void Main()
{
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("172.16.1.50");
ISubscriber pub = redis.GetSubscriber();
while (true)
{
pub.Publish(RedisChannel.Literal("channel1"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
}
}
}
sub:
using System;
using System.Threading;
using System.Threading.Tasks;
using StackExchange.Redis;
class Subscriber
{
static int id = 0;
//[System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.NoOptimization)]
static void Main()
{
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("172.16.1.50");
ISubscriber sub = redis.GetSubscriber();
Task.Run(async () => await sub.SubscribeAsync(RedisChannel.Literal("channel1"), HandleMessage));
while (true)
{
Thread.Sleep(1000);
}
}
static void HandleMessage(RedisChannel channel, RedisValue message)
{
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + $" id:{id++} Received from {channel}: {message}");
}
}
run in debug mode ,all fine!
but run in release mode, after a while,the sub program is freeze.
I add [System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.NoOptimization)] to Main(),run fine.
I dont know why... I need help,thx!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the Publisher.Main and Subscriber.Main examples in both Debug and Release modes, focusing on SubscribeAsync and HandleMessage. Compare the behavior after the subscriber freezes and inspect whether the release-only behavior can be reproduced; done means identifying the cause and establishing a reliable fix or documented limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, redis
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100