# Can not connect to Confluence Cloud topic from Java Springboot client

**URL:** <https://forum.confluent.io/t/can-not-connect-to-confluence-cloud-topic-from-java-springboot-client/4034>\
**Category:** Confluent Cloud\
**Created:** [30 January 2022 05:59 UTC](https://forum.confluent.io/t/can-not-connect-to-confluence-cloud-topic-from-java-springboot-client/4034 "2022-01-30T05:59:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rorolopezg](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rorolopezg/32/1535_2.png) [@rorolopezg](https://forum.confluent.io/u/rorolopezg)\
**Post date:** [30 January 2022 05:59 UTC](https://forum.confluent.io/t/can-not-connect-to-confluence-cloud-topic-from-java-springboot-client/4034/1 "2022-01-30T05:59:36Z")

</div>

Hi all.

I’m new in Confluent Cloud and I’m trying to send a simple event from a Java Spring Boot client to a Confluent Cloud topic. I saw some tutorial from Confluent site and some source code from github, however I can’t get it to work.

I always receive a log message like this:

`org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Bootstrap broker xxx-yyyyy.us-east1.gcp.confluent.cloud:9092 (id: -1 rack: null) disconnected`

My application.properties is:

```auto
spring.kafka.properties.sasl.mechanism=PLAIN
spring.kafka.properties.bootstrap.servers=pkc-4yyd6.us-east1.gcp.confluent.cloud:9092 
spring.kafka.properties.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username='<API KEY>' password='<API SECRET>';
spring.kafka.properties.security.protocol=SASL_SSL

```

And my Kafka configuration class is:

```auto
@Configuration

public class KafkaConfiguration {
  Logger log = LoggerFactory. *getLogger* (getClass());
  @Autowired
  private Environment env;

  @Bean
    public ProducerFactory<Integer, String> producerFactory() {
      String kafkaServer = env.getProperty("spring.kafka.properties.bootstrap.servers");
      log.info("Kafka Server: " + kafkaServer);
      return new DefaultKafkaProducerFactory<>(Map.of (
        BOOTSTRAP_SERVERS_CONFIG, kafkaServer,
        RETRIES_CONFIG , 0,
        BATCH_SIZE_CONFIG , 16384,
        LINGER_MS_CONFIG , 1,
        BUFFER_MEMORY_CONFIG , 33554432,
        KEY_SERIALIZER_CLASS_CONFIG, IntegerSerializer.class,
        VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class)
    );

  }

@Bean
 public KafkaTemplate<Integer, String> kafkaTemplate() {
    return new KafkaTemplate<>(producerFactory());
 }
}

```

Finaly, this is the producer class:

```auto
@Component

class Producer {

  @Autowired

  private KafkaTemplate<Integer, String> template;

  Faker faker;

  @EventListener(ApplicationStartedEvent.class)

  public void generate() {

     faker = Faker.instance();

      final Flux<Long> interval = Flux.interval(Duration.ofMillis (1_000));

      final Flux<String> quotes = Flux.fromStream(Stream.generate(() -> faker.hobbit().quote()));

     Flux.zip(interval, quotes)
         .map(it -> template.send("test", faker.random().nextInt(42), it.getT2())).blockLast();
    }
}

```

I appreciate your help with this.

---

<div class="post-metadata">

**Author:** ![nbommu1](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/nbommu1/32/247_2.png) [@nbommu1](https://forum.confluent.io/u/nbommu1)\
**Post date:** [15 February 2022 12:56 UTC](https://forum.confluent.io/t/can-not-connect-to-confluence-cloud-topic-from-java-springboot-client/4034/2 "2022-02-15T12:56:31Z")

</div>

have you tried with setting this property?

`ssl.endpoint.identification.algorithm=https`

---

<div class="post-metadata">

**Author:** ![nbommu1](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/nbommu1/32/247_2.png) [@nbommu1](https://forum.confluent.io/u/nbommu1)\
**Post date:** [15 February 2022 12:57 UTC](https://forum.confluent.io/t/can-not-connect-to-confluence-cloud-topic-from-java-springboot-client/4034/3 "2022-02-15T12:57:41Z")

</div>

Here is my working config file.

```auto
bootstrap.servers=<ccloud kafka>:9092
ssl.endpoint.identification.algorithm=https
security.protocol=SASL_SSL
sasl.mechanism=PLAIN
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="<USER>" password="<PASSWORD >";

```

---

<div class="post-metadata">

**Author:** ![teja22060](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/teja22060/32/2082_2.png) [@teja22060](https://forum.confluent.io/u/teja22060)\
**Post date:** [29 July 2022 06:41 UTC](https://forum.confluent.io/t/can-not-connect-to-confluence-cloud-topic-from-java-springboot-client/4034/4 "2022-07-29T06:41:33Z")

</div>

I am also facing same problem, i created confluent cloud cluster, and started spring boot service with Kafka config, but not able to send data using Kafka template send, with simple string message

---

<div class="post-metadata">

**Author:** ![alexandre1202](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/alexandre1202/32/2632_2.png) [@alexandre1202](https://forum.confluent.io/u/alexandre1202)\
**Post date:** [18 January 2023 20:08 UTC](https://forum.confluent.io/t/can-not-connect-to-confluence-cloud-topic-from-java-springboot-client/4034/5 "2023-01-18T20:08:10Z")

</div>

> [@nbommu1](#):
>
> ssl.endpoint.identification.algorithm=https

Hey guys.  
I am facing the same issue when I run my springboot application with the KafkaListener to consume from the Confluent protobuf topic message. Locally it is working fine, but not when I am using the Confluent environment.  
Please, anyone else here fixed this?

---

<div class="post-metadata">

**Author:** ![erickqe](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/erickqe/32/2837_2.png) [@erickqe](https://forum.confluent.io/u/erickqe)\
**Post date:** [28 March 2023 23:23 UTC](https://forum.confluent.io/t/can-not-connect-to-confluence-cloud-topic-from-java-springboot-client/4034/6 "2023-03-28T23:23:39Z")

</div>

@Bean  
public ProducerFactory\<String, Object\> producerFactory() {  
Map\<String, Object\> configProps = new HashMap\<\>();  
configProps.put(ProducerConfig.BOOTSTRAP\_SERVERS\_CONFIG, bootstrapAddress);  
configProps.put(ProducerConfig.KEY\_SERIALIZER\_CLASS\_CONFIG, StringSerializer.class);  
configProps.put(ProducerConfig.VALUE\_SERIALIZER\_CLASS\_CONFIG, ObjectSerializer.class);  
configProps.put(“sasl.mechanism”, “PLAIN”);  
configProps.put(“sasl.jaas.config”, “org.apache.kafka.common.security.plain.PlainLoginModule required username=‘XXXXXX’ password=‘XXXXXXXX’;”);  
configProps.put(“security.protocol”, “SASL\_SSL”);  
return new DefaultKafkaProducerFactory\<\>(configProps);

```
}

```
