# \[Solved\] Problems multicast ehcache

**URL:** <https://forums.suse.com/t/solved-problems-multicast-ehcache/1507>\
**Category:** Rancher 1.x\
**Created:** [January 21, 2016, 8:24pm UTC](https://forums.suse.com/t/solved-problems-multicast-ehcache/1507 "2016-01-21T20:24:20Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![juandavidgc](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@juandavidgc](https://forums.suse.com/u/juandavidgc)\
**Post date:** [January 21, 2016, 8:24pm UTC](https://forums.suse.com/t/solved-problems-multicast-ehcache/1507/1 "2016-01-21T20:24:20Z")

</div>

Hello everyone! I have a problem trying to configuring ehcache in a cluster environment. Let me explain more about the architecture of the application…

I have a java application running in a tomcat server. This application is wrapped in a docker image. This application works fine, and I run it using rancher and 2 machines, but the problem is that the application uses ehcache, and I’ve configured this using automatic mode. In automatic mode, ehcache uses a multicast address, and a multicast port. I’ve configured that, but the application could not replicate the cache.

Below are the configurations I used to run the application in rancher:

1. First try: I’ve exposed the ports 8080 (tcp), 4001 (tcp, used to replicate the cache), and 4446 (udp. Used for the autodiscovery with the multicasts address). I’ve used “managed” network. =\> It didn’t work…

2. Second try: I’ve exposed the ports 8080 (tcp), 4001 (tcp, used to replicate the cache), and 4446 (udp. Used for the autodiscovery with the multicasts address). I’ve used “host” network. =\> It didn’t work…

I’ve also tried exposing 4446 port with tcp, but it didn’t work neither.

Anyone can help me with this?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![juandavidgc](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@juandavidgc](https://forums.suse.com/u/juandavidgc)\
**Post date:** [January 21, 2016, 8:56pm UTC](https://forums.suse.com/t/solved-problems-multicast-ehcache/1507/2 "2016-01-21T20:56:54Z")

</div>

I forgot to write that if I run the application in a non-docker environment (in two ubuntu servers), it works fine, and it replicates the cache without any problem,

Thanks again!

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [January 22, 2016, 3:53am UTC](https://forums.suse.com/t/solved-problems-multicast-ehcache/1507/3 "2016-01-22T03:53:11Z")

</div>

The overlay network is layer 3, not layer 2. No multicast.

---

<div class="post-metadata">

**Author:** ![juandavidgc](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@juandavidgc](https://forums.suse.com/u/juandavidgc)\
**Post date:** [January 22, 2016, 11:50am UTC](https://forums.suse.com/t/solved-problems-multicast-ehcache/1507/4 "2016-01-22T11:50:54Z")

</div>

But In the second try I used host network. It should work, right? Or what are I doing wrong?

---

<div class="post-metadata">

**Author:** ![sjiveson](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sjiveson/32/966_2.png) [@sjiveson](https://forums.suse.com/u/sjiveson)\
**Post date:** [January 22, 2016, 2:36pm UTC](https://forums.suse.com/t/solved-problems-multicast-ehcache/1507/5 "2016-01-22T14:36:48Z")

</div>

Hey juandavidgc,

Shouldn’t that be TCP port 40001 rather than 4001? I believe this port is used with manual discovery and for the peer listener.

The 4446 port used for auto-discovery is also TCP, **not UDP**.

Info from here: [http://www.ehcache.org/documentation/2.8/replication/rmi-replicated-caching.html](http://www.ehcache.org/documentation/2.8/replication/rmi-replicated-caching.html).

As long as you have IP forwarding enabled (check with sysctl net.ipv4.ip\_forward) multicast should work just fine in host networking mode. Of course, each container running ehcache MUST be on a different host, they can’t both listen to the same port.

If this doesn’t get you anywhere, please post your xml config.

---

<div class="post-metadata">

**Author:** ![juandavidgc](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@juandavidgc](https://forums.suse.com/u/juandavidgc)\
**Post date:** [January 22, 2016, 3:02pm UTC](https://forums.suse.com/t/solved-problems-multicast-ehcache/1507/6 "2016-01-22T15:02:17Z")

</div>

Hello sjiveson. I’ve tested this but it didn’t work neither. Below are the files and the configuration in rancher.

Thanks!

## **ehcache.xml**
\<?xml version="1.0" encoding="UTF-8"?\>

```
<!--terracottaConfig url="localhost:9510" /-->

<!-- peer configuration -->

<!-- Listener port of this analyzer instance 8081 to put-->
<!-- <cacheManagerPeerProviderFactory
        class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
        properties="peerDiscovery=manual, rmiUrls="/>-->
<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
	properties="hostName=, peerDiscovery=automatic,multicastGroupAddress=230.0.0.1,multicastGroupPort=4446,timeToLive=64"/>

<!-- Listener port of this analyzer instance 8081 me put-->
<cacheManagerPeerListenerFactory
        class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
        properties="hostName=,port=40001,socketTimeoutMillis=2000"/>

<defaultCache eternal="true" maxElementsInMemory="500" overflowToDisk="false" memoryStoreEvictionPolicy="LFU">
    <bootstrapCacheLoaderFactory
            class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
            properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000"
            propertySeparator=","/>
</defaultCache>

<cache name="identisiteCache" logging="true" eternal="false" timeToIdleSeconds="60" maxElementsInMemory="1000"
       overflowToDisk="false" statistics="true">
    <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
                               properties="replicateAsynchronously=false, replicatePuts=true, replicateUpdates=true,
  replicateUpdatesViaCopy=false, replicateRemovals=true "/>
</cache>

<cache name="utilConfigurationCache" logging="true" eternal="true" timeToLiveSeconds="0" timeToIdleSeconds="0" maxElementsInMemory="500"
       overflowToDisk="false" statistics="true">
    <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
                               properties="replicateAsynchronously=false, replicatePuts=true, replicateUpdates=true,
  replicateUpdatesViaCopy=false, replicateRemovals=true "/>
</cache>
...
...

```

## **Dockerfile**

RUN apt-get -y install software-properties-common  
RUN apt-get -y install unzip

RUN   
echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections &&   
add-apt-repository -y ppa:webupd8team/java &&   
apt-get update &&   
apt-get install -y oracle-java7-installer &&   
rm -rf /var/lib/apt/lists/\* &&   
rm -rf /var/cache/oracle-jdk7-installer

ENV JAVA\_HOME /usr/lib/jvm/java-7-oracle

RUN mkdir /opt/app

COPY app.zip /opt/app

WORKDIR /opt/app  
RUN unzip app.zip

RUN rm -rf /opt/app/application/logs/catalina.out

RUN chmod -R a+x /opt/app/application/bin

RUN mkdir /opt/util  
COPY PropertyReplacer.jar /opt/util/

WORKDIR /opt/app/application/bin/  
ENV PATH /opt/app/application/bin:$PATH  
**EXPOSE 8080**  
**EXPOSE 40001**  
**EXPOSE 4446**  
COPY docker-entrypoint.sh /  
RUN chmod a+x /docker-entrypoint.sh  
ENTRYPOINT [“/docker-entrypoint.sh”]  
CMD [“catalina.sh”, “run”]

**Screenshot of the service configuration**

 ![](https://us1.discourse-cdn.com/flex022/uploads/suse/original/1X/8ca0c2d7b60c0084325f609ccfaf9cf18e7466a8.png)

---

<div class="post-metadata">

**Author:** ![sjiveson](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sjiveson/32/966_2.png) [@sjiveson](https://forums.suse.com/u/sjiveson)\
**Post date:** [January 28, 2016, 5:32pm UTC](https://forums.suse.com/t/solved-problems-multicast-ehcache/1507/7 "2016-01-28T17:32:21Z")

</div>

Any idea why there’s reference to 8081 in your file?

Are you certain this is correctly commented out:

If so, can you enter whichever of these commands works and post back the output - this will confirm (or not) that the ports are being bound as we expect:

```
netstat -ltn
ss -ltn

```

Also, please confirm you only have single interface configured. This would have to use host mode networking to work so this relates to the host interfaces.

---

<div class="post-metadata">

**Author:** ![juandavidgc](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@juandavidgc](https://forums.suse.com/u/juandavidgc)\
**Post date:** [February 10, 2016, 2:39pm UTC](https://forums.suse.com/t/solved-problems-multicast-ehcache/1507/8 "2016-02-10T14:39:29Z")

</div>

Thanks for your help! I solved this problem extending ehcache functionallity. I create another way to discover new members of the replica set using giddyup.

---

<div class="post-metadata">

**Author:** ![sjiveson](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sjiveson/32/966_2.png) [@sjiveson](https://forums.suse.com/u/sjiveson)\
**Post date:** [February 15, 2016, 10:47am UTC](https://forums.suse.com/t/solved-problems-multicast-ehcache/1507/9 "2016-02-15T10:47:13Z")

</div>

You’re welcome, glad you got it sorted as I was out of ideas.

---

<div class="post-metadata">

**Author:** ![mwyraz](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mwyraz](https://forums.suse.com/u/mwyraz)\
**Post date:** [April 20, 2018, 12:52pm UTC](https://forums.suse.com/t/solved-problems-multicast-ehcache/1507/10 "2018-04-20T12:52:34Z")

</div>

@sjiveson I trapped in the same problem. My idea was also to create a new discovery (DNS or rancher metadata), then I found this post. Would you mind to share your solution?  
Kind regards,  
Michael.

---

<div class="post-metadata">

**Author:** ![sjiveson](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sjiveson/32/966_2.png) [@sjiveson](https://forums.suse.com/u/sjiveson)\
**Post date:** [April 20, 2018, 1:23pm UTC](https://forums.suse.com/t/solved-problems-multicast-ehcache/1507/11 "2018-04-20T13:23:20Z")

</div>

Hey, I didn’t solve it, @juandavidgc did, perhaps he can share his solution?
