Is there a way 2 jobs can communicate on nomad

I have 2 jobs:-

  1. an api with websocket
  2. a service that sends message to the websocket of service 1

Is there a way service 2 can send message to service 1’s endpoint?

Service 1 is a public api, but i dont want to expose the websocket to the internet.

Hi @saujanya01,

It is definitely possible for applications in multiple jobs to talk to each other. This is an example job, that talks to your WebSocket application using the Nomad Service Discovery option.

job "ws-client" {
  group "ws-client" {
    task "ws-client" {
      driver = "docker"

      config {
        image   = "curlimages/curl:7.87.0"
        command = "/bin/ash"
        args    = ["local/"]

      template {
        data        = <<EOF
#!/usr/bin/env ash

while true; do
{{range nomadService "ws-test"}}
  curl -L -v http://{{.Address}}:{{.Port}}/
  sleep 3
        destination = "local/"

I hope this helps!

Hi @saujanya01,

Adding to the answer given from @Ranjandas, this is absolutely possible. The service discovery networking page is a good starting point for understanding what is possible and how to get started.

jrasell and the Nomad team