Skip to content

Commit 1ba7d0e

Browse files
committed
Fix remaining RESP3 handshake snafus
1 parent 59407b0 commit 1ba7d0e

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

tests/StackExchange.Redis.Tests/InProcessTestServer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class InProcessTestServer : MemoryCacheRedisServer
1818
private readonly ITestOutputHelper? _log;
1919
public InProcessTestServer(ITestOutputHelper? log = null)
2020
{
21+
RedisVersion = RedisFeatures.v6_0_0; // for client to expect RESP3
2122
_log = log;
2223
// ReSharper disable once VirtualMemberCallInConstructor
2324
_log?.WriteLine($"Creating in-process server: {ToString()}");

toys/KestrelRedisServer/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
var server = new MemoryCacheRedisServer
88
{
9-
RedisVersion = new(3, 0),
9+
// note: we don't support many v6 features, but some clients
10+
// want this before they'll try RESP3
11+
RedisVersion = new(6, 0),
1012
// Password = "letmein",
1113
};
1214

toys/StackExchange.Redis.Server/RedisServer.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ protected virtual TypedRedisValue Hello(RedisClient client, in RedisRequest requ
209209

210210
for (int i = 2; i < request.Count && request.TryGetCommandBytes(i, out var key); i++)
211211
{
212-
int remaining = request.Count - (i + 2);
212+
int remaining = request.Count - (i + 1);
213213
TypedRedisValue ArgFail() => TypedRedisValue.Error($"ERR Syntax error in HELLO option '{key.ToString().ToLower()}'\"");
214214
if (key.Equals(Literals.AUTH))
215215
{
@@ -225,6 +225,10 @@ protected virtual TypedRedisValue Hello(RedisClient client, in RedisRequest requ
225225
if (remaining < 1) return ArgFail();
226226
name = request.GetString(++i);
227227
}
228+
else
229+
{
230+
return ArgFail();
231+
}
228232
}
229233
}
230234

0 commit comments

Comments
 (0)