Support Questions

Find answers, ask questions, and share your expertise

Failed to construct kafka producer, ConfigException: No resolvable bootstrap urls given in bootstrap.servers

avatar
Explorer

I'm using HDP 2.3.4 with kafka 0.9

The kafka console producer/consumer worked well, but when I tried to create a simple kafka producer using scala in windows, it went into exception with error description in subject. Scala code was some sample code from git, as below:

object ProducerExample extends App {  

import java.util.Properties
import org.apache.kafka.clients.producer._

val  props = new Properties() 
props.put("bootstrap.servers", "serverX:6667")   
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer") 
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer")
props.put("security.protocol", "SASL_PLAINTEXT")
val producer = new KafkaProducer[String, String](props)    
val TOPIC="test"  

for(i<- 1 to 50){  
	val record = new ProducerRecord(TOPIC, "key", s"hello $i")  
	producer.send(record) 
}     

val record = new ProducerRecord(TOPIC, "key", "the end "+new java.util.Date) 
producer.send(record)
producer.close()
}

I'm pretty sure the bootstrap.servers setting is correct, as the console producer/consumer works with the same value.

Any comments/clues? thanks a lot!

2 REPLIES 2

avatar
Explorer

Kafka is installed on a linux box, tested console producer/consumer in the same linux box

avatar
Contributor

looks like your host name is not getting resolved. Pl check your host name. Also enable producer logs for more info.