Can't connect to typesense deployment via private network

I deployed typesense with the image typesense/typesense:0.24.0, and another Golang app. But I can’t get my golang app to talk to my typesense deployment via the DNS http://mad.private-typesense-name.internal:8108, it says connection refused, and other times it would say no such host. Both apps are deployed in Madrid

this is what the typesense Dockerfile looks like:

ADD file ... in /

CMD ["bash"]

RUN /bin/sh -c apt-get -y

RUN /bin/sh -c mkdir -p

COPY typesense-server /opt # buildkit

RUN /bin/sh -c chmod +x

EXPOSE map[8108/tcp:{}]

ENTRYPOINT ["/opt/typesense-server"]

Before deploying I removed the service_http section from the typesense fly.toml file so that It can only be reached privately.

Is there something else i might have missed?

EXPOSE map[8108/tcp:{}]

I don’t think that’s valid dockerfile syntax. Can you try changing that to

EXPOSE 8108/tcp

The Dockerfile is from the official docker image that I’m using: link. I don’t think I can change it.

What do the typesense logs show?

I got it working, but I had to specify some env vars:

[env]
  TYPESENSE_DATA_DIR = "/data"
  TYPESENSE_API_KEY = "..."

and declare a volume:

fly vol create typesense_data -r MYREGION

and add it to fly.toml:

[mounts]
  source = "typesense_data"
  destination = "/data"

I did include the env vars and the mount section too, here is the content of my fly.toml file:

app = "typesense-for-convoy"
primary_region = "mad"

[build]
  image = "typesense/typesense:0.24.0"

[mounts]
source="typesense_data"
destination="/data/typesense"

[env]
  TYPESENSE_DATA_DIR = "/data/typesense"
  TYPESENSE_ENABLE_CORS = "true"
  TYPESENSE_API_KEY = "convoy"

although I didn’t first create a volume with fly vol create.

Below is the typesense log, it keeps repeating these lines:

2023-05-04T00:52:14.628 app[32871e0b4501e8] mad [info] I20230504 00:52:14.627552 613 raft_server.cpp:545] Term: 2, last_index index: 28, committed_index: 28, known_applied_index: 28, applying_index: 0, queued_writes: 0, pending_queue_size: 0, local_sequence: 81

2023-05-04T00:52:14.628 app[32871e0b4501e8] mad [info] I20230504 00:52:14.627630 626 raft_server.h:60] Peer refresh succeeded!

2023-05-04T00:52:21.713 app[32871e0b4501e8] mad [info] I20230504 00:52:21.713387 614 batched_indexer.cpp:279] Running GC for aborted requests, req map size: 0

Ok, I figured it out - fly’s private networking feature relies on programs listening on IPv6. But typesense only supports IPv4. So instead, we can make use of flycast which will route connections through our proxy that can handle IPv4.

  1. Create a flycast IP
fly ips allocate-v6 --private
  1. Register a service for typesense in fly.toml:
[http_service]
  internal_port = 8108
  1. Deploy typesense
fly deploy
  1. Connect to it from another app:
curl http://typesense-for-convoy.flycast/

Thank you!

This worked, but after i added .flycast to the URL like so: .http://typesense-for-convoy.flycast

1 Like

Nice! I missed that part

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.