Skip to content

Subscription dies on server reset with no reconnect or indication of failure #32

@jencompgeek

Description

@jencompgeek

If a client is subscribed and the server is bounced, no attempt is made to resubscribe the client (and of course no Exception is thrown since the thread does not block on the subscribe call).

This can be reproduced by running the following test, putting a breakpoint on creation of client3 and bouncing the Redis server before continuing. "World" is not printed out.

    @Test
    public void testSubscribe() throws IOException {
        RedisClient client = new RedisClient("localhost", 6379);
        client.addListener(new SrpListener());
        client.subscribe("channel1".getBytes());
        RedisClient client2 = new RedisClient("localhost", 6379);
        client2.publish("channel1".getBytes(), "Hello".getBytes());
        RedisClient client3 = new RedisClient("localhost", 6379);
        client3.publish("channel1".getBytes(), "World".getBytes());
    }

    private class SrpListener implements ReplyListener {
        public void subscribed(byte[] name, int channels) {
        }

        public void psubscribed(byte[] name, int channels) {
        }

        public void unsubscribed(byte[] name, int channels) {
        }

        public void punsubscribed(byte[] name, int channels) {
        }

        public void message(byte[] channel, byte[] message) {
            System.out.println(new String(message));    
        }

        public void pmessage(byte[] pattern, byte[] channel, byte[] message) {
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions