Skip to content

remove the misleading prompt when connect without ip and port - #2112

Closed
fomy wants to merge 1 commit into
redis:unstablefrom
fomy:unstable
Closed

fomy wants to merge 1 commit into
redis:unstablefrom
fomy:unstable

Conversation

@fomy

@fomy fomy commented Oct 30, 2014

Copy link
Copy Markdown

Hi all,

When redis-cli re-connects (for example, reboot server and then reconnect) to redis-server without explicit ip and port, redis-cli will run cliConnect(1) and then send a "connect" command to the server (see redis-cli.c:942).
Then, redis-cli will show an error prompt "(error) ERR unknown command 'connect'", even if the connection is successful.
I think the prompt is misleading, and suggest to modify the codes around redis-cli.c:917, which is straightforward.

Best regards
Min Fu

@mattsta

mattsta commented Oct 30, 2014

Copy link
Copy Markdown
Contributor

It looks like you're trying to reconnect by typing "connect" again?

Any command typed will try to automatically reconnect to a Redis server, so you only run "connect IP port" if you want to connect to a different server.

Example:

% ./redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> set a b
Could not connect to Redis at 127.0.0.1:6379: Connection refused

[redis server started in another terminal window]

not connected> set a b
OK
127.0.0.1:6379> 

Notice how the last "set a b" caused redis-cli to auto-connect to the server it was originally trying to talk to.

@mattsta mattsta closed this Oct 30, 2014
@fomy

fomy commented Oct 31, 2014

Copy link
Copy Markdown
Author

Yes, I try "connect" without ip and port. The auto-connect is successful but the error prompt I think is misleading.

@mattsta

mattsta commented Oct 31, 2014

Copy link
Copy Markdown
Contributor

Yeah, that does make sense. It shouldn't be sending 'connect' to the server since it's a local request.

mattsta added a commit to mattsta/redis that referenced this pull request Oct 31, 2014
Also add an alias for connect to "con" because typing "connect"
takes too long.

New cli commands (with shorthand options):
  - enable/en cluster = enable cluster mode
  - disable/dis/no cluster = disable cluster mode

Example usage:
127.0.0.1:7000> get a
(error) MOVED 15495 127.0.0.1:7002
127.0.0.1:7000> en cluster
127.0.0.1:7000> get a
-> Redirected to slot [15495] located at 127.0.0.1:7002
(nil)
127.0.0.1:7002>

(The first "get" fails with MOVED, then we "en cluster" to enable
cluster redirect following, then the second "get" follows the
MOVED and works.)

This commit also keeps client-only commands on the client
so they don't leak to the server.

Fixes redis#2112 as well
mattsta added a commit to mattsta/redis that referenced this pull request Dec 11, 2014
Also add an alias for connect to "con" because typing "connect"
takes too long.

New cli commands (with shorthand options):
  - enable/en cluster = enable cluster mode
  - disable/dis/no cluster = disable cluster mode

Example usage:
127.0.0.1:7000> get a
(error) MOVED 15495 127.0.0.1:7002
127.0.0.1:7000> en cluster
127.0.0.1:7000> get a
-> Redirected to slot [15495] located at 127.0.0.1:7002
(nil)
127.0.0.1:7002>

(The first "get" fails with MOVED, then we "en cluster" to enable
cluster redirect following, then the second "get" follows the
MOVED and works.)

This commit also keeps client-only commands on the client
so they don't leak to the server.

Fixes redis#2112 as well
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

Successfully merging this pull request may close these issues.

2 participants