Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context #694

Closed
Kilowhisky opened this issue Jul 6, 2023 · 1 comment

Comments

@Kilowhisky
Copy link
Contributor

Describe the bug
StackExchange.Redis (C#) Redis client opens a SUBSCRIBE channel as part of its normal connection process. The client then sends PING routinely on this channel to make sure its alive.

The tile38 server does not accept PING though.

for {
for _, msg := range msgs {
start = time.Now()
var kind int
var un bool
switch msg.Command() {
case "quit":
writeOK()
return nil
case "psubscribe":
kind, un = pubsubPattern, false
case "punsubscribe":
kind, un = pubsubPattern, true
case "subscribe":
kind, un = pubsubChannel, false
case "unsubscribe":
kind, un = pubsubChannel, true
default:
writeOnlyPubsubErr()
continue
}

Expected behavior
It should respect the PING command as the error message it sends back explicitly says it does.

writeOnlyPubsubErr := func() {
switch outputType {
case JSON:
write([]byte(`{"ok":false` +
`,"err":"only (P)SUBSCRIBE / (P)UNSUBSCRIBE / ` +
`PING / QUIT allowed in this context"` +
`,"elapsed":"` + time.Since(start).String() + `"}`))
case RESP:
write([]byte("-ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / " +
"PING / QUIT allowed in this context\r\n"))
}

Logs

This is the error as the client closes the connection due to ProtocolError

"2023-07-06T21:53:56.6202858Z", "level": "WARN", "logger": "Tina.Tile38.Tile38ConnectionProvider", "message": "ConnectionFailed CHRIS-TOWER(SE.Redis-v2.6.116.40240) Subscription, ProtocolFailure, Unspecified/tile38-node-1.default:30512, StackExchange.Redis.RedisConnectionException: ProtocolFailure (None, last-recv: 79) on tile38-node-1.default:30512/Subscription, Idle/ComputeResult, last: PING, origin: SetResult, outstanding: 0, last-read: 0s ago, last-write: 0s ago, keep-alive: 60s, state: ConnectedEstablished, mgr: 9 of 10 available, in: 0, in-pipe: 79, out-pipe: 0, last-heartbeat: 0s ago, last-mbeat: 0s ago, global: 0s ago, v: 2.6.116.40240\r\n ---> StackExchange.Redis.RedisServerException: Error: ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context\r\n   --- End of inner exception stack trace ---" }

The server side appears to open and then drop the connection:

2023-07-06 14:37:42 { "time": "2023-07-06 21:37:42.6164", "level": "Info", "message": "live 192.168.65.4:34724" }
2023-07-06 14:37:42 { "time": "2023-07-06 21:37:42.6164", "level": "Debug", "message": "pubsub open" }
2023-07-06 14:37:42 { "time": "2023-07-06 21:37:42.6164", "level": "Debug", "message": "pubsub closed" }
2023-07-06 14:37:42 { "time": "2023-07-06 21:37:42.6164", "level": "Info", "message": "not live 192.168.65.4:39744" }

Operating System (please complete the following information):

  • OS: Linux
  • CPU: amd64
  • Version: edge
  • Container: Kubernetes (Docker Desktop)
@Kilowhisky
Copy link
Contributor Author

Merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant