embedded-redis icon indicating copy to clipboard operation
embedded-redis copied to clipboard

Annoying alert when starting redis embedded.

Open gochev opened this issue 10 years ago • 20 comments

When starting redis embedded as part of another applicaiton (spring boot in this case) i am getting each time a very very annoying alert message ( see screenshot for more details ).

And this is happening each time.. I do use solr embedded and elastic search embedded and tomcat and hazelcast but only redis shows this bad confirmation, none of the other asks me do I want to allow incoming connection.. this just looks very bad and basically makes redis unusable since it doesn't look very professional.

screen shot 2015-04-14 at 14 04 27

gochev avatar Apr 14 '15 11:04 gochev

First of all, embedded-redis aim was to be able to run integration tests without external dependencies (like redis server running somewhere).

Whenever you use embedded Tomcat and/or Solr, you actually use some Java code - you stay within the boundaries of a single process. On the other hand, embedded-redis runs redis executable in a separate process from a shell. I guess that your firewall recognizes it as harmful.

Not sure what to think about it. On the one hand, it is outside of the scope of this project, but on the other.. I should look into that..

kstyrc avatar Apr 14 '15 11:04 kstyrc

Any more hints on how to reproduce the issue? How do you run it exactly?

kstyrc avatar Apr 14 '15 11:04 kstyrc

I see :( but bad indeed this allow .. I hope doesnt show up on windows machines :(

anyway I answered in the other bug but I am adding the comment here as well :

We have a spring boot application and we import the following configuration that starts the embedded redis.

@Configuration public class PlatformCoreSessionConfig {

@Bean(name = "sessionStrategy")
public HttpSessionStrategy defaultSessionStrategy() {
    final CookieHttpSessionStrategy result = new CookieHttpSessionStrategy();
    result.setCookieName("SESSION");
    return result;
}

@Bean
public static RedisServerBean redisServer() {
    return new RedisServerBean();
}

@Bean(name = { "defaultRedisSessionRepository", "sessionRepository" })
public SessionRepository defaultRedisSessionRepository(JedisConnectionFactory redisCF) throws Exception {
    return new RedisOperationsSessionRepository(redisCF);
}

@Bean
public JedisConnectionFactory connectionFactory(final Environment environment) throws Exception {
    final JedisConnectionFactory jcf = new JedisConnectionFactory();
    jcf.setHostName(environment.getProperty("platform.redis.host", String.class, "localhost"));
    jcf.setPort(environment.getProperty("platform.redis.port", Integer.class, Protocol.DEFAULT_PORT));
    jcf.setPassword(environment.getProperty("platform.redis.password", String.class, ""));
    jcf.afterPropertiesSet();

    return jcf;
}

/**
 * Implements BeanDefinitionRegistryPostProcessor to ensure this Bean
 * is initialized before any other Beans. Specifically, we want to ensure
 * that the Redis Server is started before RedisHttpSessionConfiguration
 * attempts to enable Keyspace notifications.
 */
static class RedisServerBean implements InitializingBean, DisposableBean, BeanDefinitionRegistryPostProcessor {
    private RedisServer redisServer;

    public void afterPropertiesSet() throws Exception {
        redisServer = new RedisServer(Protocol.DEFAULT_PORT);
        redisServer.start();
    }

    public void destroy() throws Exception {
        if (redisServer != null) {
            redisServer.stop();
        }
    }

    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
    }

    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    }
}

}

gochev avatar Apr 14 '15 12:04 gochev

I am a bit worried that if you start RedisServer from within Tomcat context, it can enforce its java policy.. Will try to reproduce this on Linux (unfortunately I have no MacOS to try ;<).

kstyrc avatar Apr 14 '15 12:04 kstyrc

well on linux .. at least it looks everything works as expected :( the two strange things I am noticing are only under mac os x ..

gochev avatar Apr 15 '15 06:04 gochev

I would love to investigate the issue, but it will be hard for me without MacOS. Is there any way to run MacOS on a VM?

kstyrc avatar Apr 15 '15 06:04 kstyrc

You can run MacOS X on VMware workstation for example :) for sure .. however the license says that in order to run it you have to "have mac" I mean it is illigal to run it on a NON mac machine :D however you can do that of course. VirtualBox maybe also support Mac OS X Guests this days but never tried that.. I have used only vmware workstation to run mac os x guest on windows host machine ( http://www.sysprobs.com/vmware-workstation-8-0-8-0-1-unlocker-to-run-mac-os-x-guest-in-windows-7 )

I am using Yosemite the latest up2date 10.10.3 (but I guess 10.10.0 will work the same)

gochev avatar Apr 16 '15 07:04 gochev

This is due to your firewall. I have to turn mine off when running unit tests (I can't click fast enough to allow it). System Preferences -> Security and Privacy -> (click lock at bottom to make changes, enter password) Click turn off firewall.

Alternatively, you can enable it in the firewall options (hit the plus button if it's not there): screen shot 2015-04-25 at 12 29 00 pm

bhowell2 avatar Apr 25 '15 17:04 bhowell2

similar problem on windows. i think because the redis server executable is run from a varying temp dir (like c:\users\dummy\appdata\local\temp\1430045057907-0\redis-server-2.8.19.exe), the windows firewall detects it as "new" application every time asking to allow/deny. but even when clicking allow, it seems that is too late, app quits with stacktrace like "no connection...".

zyro23 avatar Apr 26 '15 10:04 zyro23

@zyro23 yes exactly this is the issue.

The problem is the redis-embedded starts each time from a different folder.. for example : /private/var/folders/81/4b80lf6x533gsbx5wyhvzyg00000gn/T/1430215668163-0/redis-server-2.8.19.app

which means.. that ones I grand it permission to start this permission doesnt stay, instead it asks me again and again and again and what @bhowell2 is saying is undoable ( I mean to add it in the firewall application list)

Is it possible the redis-server to be started from a non randomly generated name folder each time ? this way the firewall issue will not be an issue.

gochev avatar Apr 28 '15 10:04 gochev

Yeah, sorry, I realized a little after that adding it to the list was not viable as it was random every time. Hopefully disabling your firewall is an option for you until it's fixed!

Edit: Fixed autocorrect!

bhowell2 avatar Apr 28 '15 14:04 bhowell2

To avoid the windows firewall alert it's possible to only bind to localhost (RedisServer.builder().setting("bind 127.0.0.1")...build(). At least that works for me.

cleiter avatar Jun 29 '15 10:06 cleiter

Hi, will try to make the executable dir to be stable in the next release.

kstyrc avatar Sep 28 '15 19:09 kstyrc

cleiter's solution works on windows. Many thanks!

ghost avatar Feb 12 '16 14:02 ghost

verified on Mac El Capitan that @cleiter 's solution worked.

platinummonkey avatar Feb 18 '16 21:02 platinummonkey

@cleiter 's solution also worked for me on Windows.

Thank you

comauguste avatar Jul 27 '17 18:07 comauguste

Is there a similar solution for RedisCluster? I don't see a settings() API for RedisCluster

anirudhjayakumar avatar Sep 20 '17 16:09 anirudhjayakumar

Doesn't look like it will be fixed for RedisCluster soon... :(

MichaelSp avatar May 03 '18 16:05 MichaelSp

Any plan to release a version that fixes this out of the box?

tmack8001 avatar Dec 11 '19 15:12 tmack8001

Was this ever fixed with RedisCluster?

taylorcressy avatar Feb 07 '20 16:02 taylorcressy