title: How do I connect my sample kafka producer application to a remote kafka server?
body: <p><a href="https://www.javainuse.com/spring/spring-boot-apache-kafka-hello-world" rel="nofollow noreferrer">https://www.javainuse.com/spring/spring-boot-apache-kafka-hello-world</a></p>
  <p>I followed this example to build a simple Kafka producer for some testing. However, my Kafka instance is not local and is managed by my company's infrastructure team, so it is running on a remote server. I have the address and port it is running on, but I am unsure how to configure my application to connect to it. Do I need to use an application.properties file to define the kafka address pool or something like this?</p>
  <pre><code>spring.kafka.bootstrap-servers=[kafka-server-1:port],[kafka-server-2:port]
  spring.kafka.consumer.group-id=my-sample-group
  spring.kafka.security.protocol=SSL
  </code></pre>
  <p>In the tutorial I was following for the consumer I have something like this in my application.properties but I'm not sure if it's the same for the producer or should be different. The second value here seems to be specific to the consumer and based on the autocomplete in my IDE I'm not seeing a similar value for producers.</p>
  <p>Any help is appreciated</p>
  <p>I've changed my code around and followed the example at <a href="https://docs.spring.io/spring-kafka/reference/html/#spring-boot-producer-app" rel="nofollow noreferrer">https://docs.spring.io/spring-kafka/reference/html/#spring-boot-producer-app</a></p>
  <p>Now when I try to connect the output is just alternating between WARN messages about the 2 kafka servers in my connection pool:</p>
  <p><code>2021-11-10 11:44:29.609  WARN 11839 --- [| adminclient-1] org.apache.kafka.clients.NetworkClient   : [AdminClient clientId=adminclient-1] Connection to node -2 (kafka1.mycompany.com/[some-ip-address]:9092) terminated during authentication. This may happen due to any of the following reasons: (1) Authentication failed due to invalid credentials with brokers older than 1.0.0, (2) Firewall blocking Kafka TLS traffic (eg it may only allow HTTPS traffic), (3) Transient network issue.</code></p>
  <p><code>2021-11-10 11:44:29.798  WARN 11839 --- [| adminclient-1] org.apache.kafka.clients.NetworkClient   : [AdminClient clientId=adminclient-1] Connection to node -1 (kafka2.mycompany.com/[some-ip-address]:9092) terminated during authentication. This may happen due to any of the following reasons: (1) Authentication failed due to invalid credentials with brokers older than 1.0.0, (2) Firewall blocking Kafka TLS traffic (eg it may only allow HTTPS traffic), (3) Transient network issue. </code></p>
  <p>At the beginning it seems to output some information about the kafka setup. Maybe there is some info there about which additional params I might need in my application.properties to be able to actual connect.</p>
  <pre><code>bootstrap.servers = [kafka1.mycompany.com:9092, kafka2.mycompany.com:9092]
      client.dns.lookup = use_all_dns_ips
      client.id = 
      connections.max.idle.ms = 300000
      default.api.timeout.ms = 60000
      metadata.max.age.ms = 300000
      metric.reporters = []
      metrics.num.samples = 2
      metrics.recording.level = INFO
      metrics.sample.window.ms = 30000
      receive.buffer.bytes = 65536
      reconnect.backoff.max.ms = 1000
      reconnect.backoff.ms = 50
      request.timeout.ms = 30000
      retries = 2147483647
      retry.backoff.ms = 100
      sasl.client.callback.handler.class = null
      sasl.jaas.config = null
      sasl.kerberos.kinit.cmd = /usr/bin/kinit
      sasl.kerberos.min.time.before.relogin = 60000
      sasl.kerberos.service.name = null
      sasl.kerberos.ticket.renew.jitter = 0.05
      sasl.kerberos.ticket.renew.window.factor = 0.8
      sasl.login.callback.handler.class = null
      sasl.login.class = null
      sasl.login.refresh.buffer.seconds = 300
      sasl.login.refresh.min.period.seconds = 60
      sasl.login.refresh.window.factor = 0.8
      sasl.login.refresh.window.jitter = 0.05
      sasl.mechanism = GSSAPI
      security.protocol = SSL
      security.providers = null
      send.buffer.bytes = 131072
      socket.connection.setup.timeout.max.ms = 127000
      socket.connection.setup.timeout.ms = 10000
      ssl.cipher.suites = null
      ssl.enabled.protocols = [TLSv1.2, TLSv1.3]
      ssl.endpoint.identification.algorithm = https
      ssl.engine.factory.class = null
      ssl.key.password = null
      ssl.keymanager.algorithm = SunX509
      ssl.keystore.certificate.chain = null
      ssl.keystore.key = null
      ssl.keystore.location = null
      ssl.keystore.password = null
      ssl.keystore.type = JKS
      ssl.protocol = TLSv1.3
      ssl.provider = null
      ssl.secure.random.implementation = null
      ssl.trustmanager.algorithm = PKIX
      ssl.truststore.certificates = null
      ssl.truststore.location = null
      ssl.truststore.password = null
      ssl.truststore.type = JKS
  </code></pre>