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

Annoying alert when starting redis embedded. #45

Open
gochev opened this issue Apr 14, 2015 · 20 comments
Open

Annoying alert when starting redis embedded. #45

gochev opened this issue Apr 14, 2015 · 20 comments

Comments

@gochev
Copy link

gochev commented Apr 14, 2015

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

@kstyrc
Copy link
Owner

kstyrc commented Apr 14, 2015

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
Copy link
Owner

kstyrc commented Apr 14, 2015

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

@gochev
Copy link
Author

gochev commented Apr 14, 2015

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 {
    }
}

}

@kstyrc
Copy link
Owner

kstyrc commented Apr 14, 2015

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 ;<).

@gochev
Copy link
Author

gochev commented Apr 15, 2015

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

@kstyrc
Copy link
Owner

kstyrc commented Apr 15, 2015

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?

@gochev
Copy link
Author

gochev commented Apr 16, 2015

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)

@bhowell2
Copy link

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

@zyro23
Copy link

zyro23 commented Apr 26, 2015

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...".

@gochev
Copy link
Author

gochev commented Apr 28, 2015

@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.

@bhowell2
Copy link

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!

@cleiter
Copy link

cleiter commented Jun 29, 2015

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.

@kstyrc
Copy link
Owner

kstyrc commented Sep 28, 2015

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

@ghost
Copy link

ghost commented Feb 12, 2016

cleiter's solution works on windows. Many thanks!

@platinummonkey
Copy link

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

@comauguste
Copy link

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

Thank you

@anirudhjayakumar
Copy link

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

@MichaelSp
Copy link

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

MichaelSp added a commit to MichaelSp/embedded-redis that referenced this issue May 15, 2018
jklukas added a commit to mozilla/gcp-ingestion that referenced this issue Nov 14, 2018
On my machine, each run of tests would cause a MacOS popup every time
an embedded RedisServer is initialized, warning about a process establishing
an incoming network connection. By binding to localhost, the OS doesn't get
worried.

Solution documented in
kstyrc/embedded-redis#45 (comment)
jklukas added a commit to mozilla/gcp-ingestion that referenced this issue Nov 14, 2018
On my machine, each run of tests would cause a MacOS popup every time
an embedded RedisServer is initialized, warning about a process establishing
an incoming network connection. By binding to localhost, the OS doesn't get
worried.

Solution documented in
kstyrc/embedded-redis#45 (comment)
@tmack8001
Copy link

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

@taylorcressy
Copy link

Was this ever fixed with RedisCluster?

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