title: Kafka - SaslAuthenticationException: Failed to configure SaslClientAuthenticator
body: <p>I connect my app to Kafka through SASL_SSL using keytab. At first it worked well, but once it got an error. How to fix this and avoid such errors in future? stacktrace is bellow.</p>
  
  <pre><code>java.io.IOException: Channel could not be created for socket java.nio.channels.SocketChannel[closed]
      at org.apache.kafka.common.network.Selector.buildAndAttachKafkaChannel(Selector.java:298)
      at org.apache.kafka.common.network.Selector.registerChannel(Selector.java:280)
      at org.apache.kafka.common.network.Selector.connect(Selector.java:215)
      at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:864)
      at org.apache.kafka.clients.NetworkClient.access$700(NetworkClient.java:64)
      at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:1035)
      at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:920)
      at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:508)
      at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:239)
      at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:163)
      at java.base/java.lang.Thread.run(Thread.java:834)
  Caused by: org.apache.kafka.common.KafkaException: org.apache.kafka.common.errors.SaslAuthenticationException: Failed to configure SaslClientAuthenticator
      at org.apache.kafka.common.network.SaslChannelBuilder.buildChannel(SaslChannelBuilder.java:205)
      at org.apache.kafka.common.network.Selector.buildAndAttachKafkaChannel(Selector.java:289)
      ... 10 common frames omitted
  Caused by: org.apache.kafka.common.errors.SaslAuthenticationException: Failed to configure SaslClientAuthenticator
  Caused by: org.apache.kafka.common.KafkaException: Principal could not be determined from Subject, this may be a transient failure due to Kerberos re-login
      at org.apache.kafka.common.security.authenticator.SaslClientAuthenticator.firstPrincipal(SaslClientAuthenticator.java:441)
      at org.apache.kafka.common.security.authenticator.SaslClientAuthenticator.&lt;init&gt;(SaslClientAuthenticator.java:135)
      at org.apache.kafka.common.network.SaslChannelBuilder.buildClientAuthenticator(SaslChannelBuilder.java:244)
      at org.apache.kafka.common.network.SaslChannelBuilder.buildChannel(SaslChannelBuilder.java:194)
      at org.apache.kafka.common.network.Selector.buildAndAttachKafkaChannel(Selector.java:289)
      at org.apache.kafka.common.network.Selector.registerChannel(Selector.java:280)
      at org.apache.kafka.common.network.Selector.connect(Selector.java:215)
      at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:864)
      at org.apache.kafka.clients.NetworkClient.access$700(NetworkClient.java:64)
      at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:1035)
      at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:920)
      at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:508)
      at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:239)
      at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:163)
      at java.base/java.lang.Thread.run(Thread.java:834)
  </code></pre>