Unable to connect to transactor from/to EC2 instances

I’m running Datomic on prem in AWS, backed by Postgres storage.

I have an EC2 instance, call it transactor-instance, for running the transactor via bin/transactor production-transactor.properties where production-transactor.properties has the following contents

protocol=sql
host=0.0.0.0
port=4334

license-key=XXX...

sql-url=jdbc:postgresql://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.us-west-1.rds.amazonaws.com:5432/datomic
sql-user=XXX
sql-password=XXXXXXXXXXXXXXXXXXXXXXXX
sql-driver-class=org.postgresql.Driver

...

And as expected I see this print out

Launching with Java options -server -Xms1g -Xmx1g -XX:+UseG1GC -XX:MaxGCPauseMillis=50
Starting datomic:sql://<DB-NAME>?jdbc:postgresql://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.us-west-1.rds.amazonaws.com:5432/datomic?user=XXX&password=XXXXXXXXXXXXXXXXXXXXXXXX, you may need to change the user and password parameters to work with your jdbc driver ...
System started datomic:sql://<DB-NAME>?jdbc:postgresql://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.us-west-1.rds.amazonaws.com:5432/datomic?user=XXX&password=XXXXXXXXXXXXXXXXXXXXXXXX, you may need to change the user and password parameters to work with your jdbc driver

If I start a Clojure repl on transactor-instance and run

(datomic.api/connect "datomic:sql://ucv?jdbc:postgresql://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.us-west-1.rds.amazonaws.com:5432/datomic?user=XXX&password=XXXXXXXXXXXXXXXXXXXXXXXX")

It works as expected and I get a datomic connection.

But if I start a Clojure repl (Peer library) on another EC2 instance, call it peer-instance, in the same VPC and same security groups I get this error.

INFO [datomic.domain:118] - {:event :cache/create, :cache-bytes 477364224, :pid 3773, :tid 17}
INFO [datomic.process-monitor:34] - {:event :metrics/initializing, :metricsCallback clojure.core/identity, :phase :begin, :pid 3773, :tid 17}
INFO [datomic.process-monitor:34] - {:event :metrics/initializing, :metricsCallback clojure.core/identity, :msec 0.517, :phase :end, :pid 3773, :tid 17}
INFO [datomic.process-monitor:57] - {:metrics/started clojure.core/identity, :pid 3773, :tid 17}
INFO [datomic.process-monitor:44] - {:AvailableMB 713.0, :ObjectCacheCount 0, :event :metrics, :pid 3773, :tid 16}
DEBUG [datomic.peer:666] - {:event :peer/get-connection, :cluster-conf {:protocol :sql, :db-name "ucv", :system-root "jdbc:postgresql://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.us-west-1.rds.amazonaws.com:5432/datomic?user=XXX&password=XXXXXXXXXXXXXXXXXXXXXXXX"}, :phase :begin, :pid 3773, :tid 17}
DEBUG [datomic.process-monitor:45] - {:event :metrics/report, :phase :begin, :pid 3773, :tid 16}
DEBUG [datomic.process-monitor:45] - {:event :metrics/report, :msec 1.72, :phase :end, :pid 3773, :tid 16}
INFO [datomic.kv-cluster:264] - {:event :kv-cluster/get-pod, :pod-key "pod-catalog", :phase :begin, :pid 3773, :tid 16}
DEBUG [datomic.kv-cluster:281] - {:event :kv-cluster/pod-size, :bytes 123, :chunks 1, :pid 3773, :tid 16}
INFO [datomic.kv-cluster:264] - {:event :kv-cluster/get-pod, :pod-key "pod-catalog", :msec 8.57, :phase :end, :pid 3773, :tid 16}
DEBUG [datomic.coordination:127] - {:event :coord/lookup-transactor-endpoint, :phase :begin, :pid 3773, :tid 17}
DEBUG [datomic.kv-cluster:221] - {:event :kv-cluster/get-ref, :ref-key "pod-coord", :phase :begin, :pid 3773, :tid 16}
DEBUG [datomic.kv-cluster:221] - {:event :kv-cluster/get-ref, :ref-key "pod-coord", :msec 2.12, :phase :end, :pid 3773, :tid 16}
DEBUG [datomic.coordination:127] - {:event :coord/lookup-transactor-endpoint, :msec 5.6, :phase :end, :pid 3773, :tid 17}
INFO [datomic.peer:221] - {:event :peer/connect-transactor, :host "0.0.0.0", :alt-host nil, :port 4334, :version "0.9.5703", :pid 3773, :tid 17}
DEBUG [datomic.peer:222] - {:event :peer/create-connection-impl, :cluster-conf {:protocol :sql, :db-name "ucv", :system-root "jdbc:postgresql://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.us-west-1.rds.amazonaws.com:5432/datomic?user=ucv&password=XXXXXXXXXXXXXXXXXXXXXXXX", :db-id "ucv-ea453740-431a-4106-9d45-37a34c7d8c36"}, :phase :begin, :pid 3773, :tid 17}
DEBUG [datomic.connector:99] - {:event :peer/hornet-connect, :host "0.0.0.0", :pid 3773, :tid 17}
DEBUG [io.netty.util.internal.logging.InternalLoggerFactory:71] - Using SLF4J as the default logging framework
DEBUG [io.netty.util.internal.PlatformDependent0:76] - -Dio.netty.noUnsafe: false
DEBUG [io.netty.util.internal.PlatformDependent0:76] - Java version: 8
DEBUG [io.netty.util.internal.PlatformDependent0:71] - sun.misc.Unsafe.theUnsafe: available
DEBUG [io.netty.util.internal.PlatformDependent0:71] - sun.misc.Unsafe.copyMemory: available
DEBUG [io.netty.util.internal.PlatformDependent0:71] - java.nio.Buffer.address: available
DEBUG [io.netty.util.internal.PlatformDependent0:71] - direct buffer constructor: available
DEBUG [io.netty.util.internal.PlatformDependent0:76] - java.nio.Bits.unaligned: available, true
DEBUG [io.netty.util.internal.PlatformDependent0:71] - jdk.internal.misc.Unsafe.allocateUninitializedArray(int): unavailable prior to Java9
DEBUG [io.netty.util.internal.PlatformDependent0:76] - java.nio.DirectByteBuffer.<init>(long, int): available
DEBUG [io.netty.util.internal.PlatformDependent:76] - sun.misc.Unsafe: available
DEBUG [io.netty.util.internal.PlatformDependent:76] - -Dio.netty.tmpdir: /tmp (java.io.tmpdir)
DEBUG [io.netty.util.internal.PlatformDependent:76] - -Dio.netty.bitMode: 64 (sun.arch.data.model)
DEBUG [io.netty.util.internal.PlatformDependent:76] - -Dio.netty.noPreferDirect: false
DEBUG [io.netty.util.internal.PlatformDependent:76] - -Dio.netty.maxDirectMemory: 954728448 bytes
DEBUG [io.netty.util.internal.PlatformDependent:76] - -Dio.netty.uninitializedArrayAllocationThreshold: -1
DEBUG [io.netty.util.internal.CleanerJava6:71] - java.nio.ByteBuffer.cleaner(): available
DEBUG [io.netty.util.ResourceLeakDetector:81] - -Dio.netty.leakDetection.level: simple
DEBUG [io.netty.util.ResourceLeakDetector:81] - -Dio.netty.leakDetection.targetRecords: 4
DEBUG [io.netty.channel.MultithreadEventLoopGroup:76] - -Dio.netty.eventLoopThreads: 4
DEBUG [io.netty.channel.nio.NioEventLoop:76] - -Dio.netty.noKeySetOptimization: false
DEBUG [io.netty.channel.nio.NioEventLoop:76] - -Dio.netty.selectorAutoRebuildThreshold: 512
DEBUG [io.netty.util.internal.PlatformDependent:71] - org.jctools-core.MpscChunkedArrayQueue: available
DEBUG [io.netty.util.internal.InternalThreadLocalMap:76] - -Dio.netty.threadLocalMap.stringBuilder.initialSize: 1024
DEBUG [io.netty.util.internal.InternalThreadLocalMap:76] - -Dio.netty.threadLocalMap.stringBuilder.maxSize: 4096
DEBUG [io.netty.buffer.PooledByteBufAllocator:76] - -Dio.netty.allocator.numHeapArenas: 4
DEBUG [io.netty.buffer.PooledByteBufAllocator:76] - -Dio.netty.allocator.numDirectArenas: 4
DEBUG [io.netty.buffer.PooledByteBufAllocator:76] - -Dio.netty.allocator.pageSize: 8192
DEBUG [io.netty.buffer.PooledByteBufAllocator:76] - -Dio.netty.allocator.maxOrder: 11
DEBUG [io.netty.buffer.PooledByteBufAllocator:76] - -Dio.netty.allocator.chunkSize: 16777216
DEBUG [io.netty.buffer.PooledByteBufAllocator:76] - -Dio.netty.allocator.tinyCacheSize: 512
DEBUG [io.netty.buffer.PooledByteBufAllocator:76] - -Dio.netty.allocator.smallCacheSize: 256
DEBUG [io.netty.buffer.PooledByteBufAllocator:76] - -Dio.netty.allocator.normalCacheSize: 64
DEBUG [io.netty.buffer.PooledByteBufAllocator:76] - -Dio.netty.allocator.maxCachedBufferCapacity: 32768
DEBUG [io.netty.buffer.PooledByteBufAllocator:76] - -Dio.netty.allocator.cacheTrimInterval: 8192
DEBUG [io.netty.buffer.PooledByteBufAllocator:76] - -Dio.netty.allocator.useCacheForAllThreads: true
DEBUG [io.netty.channel.DefaultChannelId:76] - -Dio.netty.processId: 3773 (auto-detected)
DEBUG [io.netty.util.NetUtil:76] - -Djava.net.preferIPv4Stack: false
DEBUG [io.netty.util.NetUtil:76] - -Djava.net.preferIPv6Addresses: false
DEBUG [io.netty.util.NetUtil:86] - Loopback interface: lo (lo, 0:0:0:0:0:0:0:1%lo)
DEBUG [io.netty.util.NetUtil:81] - /proc/sys/net/core/somaxconn: 128
DEBUG [io.netty.channel.DefaultChannelId:76] - -Dio.netty.machineId: 02:ef:d9:ff:fe:5f:3a:e0 (auto-detected)
DEBUG [io.netty.buffer.ByteBufUtil:76] - -Dio.netty.allocator.type: pooled
DEBUG [io.netty.buffer.ByteBufUtil:76] - -Dio.netty.threadLocalDirectBufferSize: 65536
DEBUG [io.netty.buffer.ByteBufUtil:76] - -Dio.netty.maxThreadLocalCharBufferSize: 16384
DEBUG [datomic.connector:118] - {:event :peer/hornet-connect-failed, :host "0.0.0.0", :pid 3773, :tid 17}
DEBUG [datomic.peer:222] - {:event :peer/create-connection-impl, :cluster-conf {:protocol :sql, :db-name "ucv", :system-root "jdbc:postgresql://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.us-west-1.rds.amazonaws.com:5432/datomic?user=ucv&password=XXXXXXXXXXXXXXXXXXXXXXXX", :db-id "ucv-ea453740-431a-4106-9d45-37a34c7d8c36"}, :msec 248.0, :phase :end, :threw clojure.lang.ExceptionInfo, :pid 3773, :tid 17}
DEBUG [datomic.peer:666] - {:event :peer/get-connection, :cluster-conf {:protocol :sql, :db-name "ucv", :system-root "jdbc:postgresql://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.us-west-1.rds.amazonaws.com:5432/datomic?user=ucv&password=XXXXXXXXXXXXXXXXXXXXXXXX"}, :msec 376.0, :phase :end, :threw clojure.lang.ExceptionInfo, :pid 3773, :tid 17}

ActiveMQNotConnectedException AMQ119007: Cannot connect to server(s). Tried with all available servers.  org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory (ServerLocatorImpl.java:799)

I can see that it’s able to connect to the storage but not the transactor. Not sure why I’m not able to connect from peer-instance.

Both transactor-instance and peer-instance have these inbound rules.

Both transactor-instance and peer-instance have these outbound rules.

I figured it out, as the docs suggested it was a misconfigured host.

https://docs.datomic.com/on-prem/storage.html#dynamodb-transactor-properties

Those docs are for DynamoDB but they also applied to my situation.

I needed to set the host value to the Public DNS provided by Amazon.