Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't connect to embedded server message #104

Open
darthmiguel opened this issue Feb 21, 2018 · 1 comment
Open

can't connect to embedded server message #104

darthmiguel opened this issue Feb 21, 2018 · 1 comment

Comments

@darthmiguel
Copy link

Hi I am using this code to test that my Kafka Producer is correctly writing to kafka

describe("publish message to kafka topic")
{
it("should publish the message to kafka topic") {

  implicit val config = EmbeddedKafkaConfig(kafkaPort = 6666)
  implicit  val deserializer = new StringDeserializer
  val message = "this is a test message"
  withRunningKafka {
    KP.configure("localhost:6666")
    KP.send("test", message)
    consumeFirstMessageFrom("test") should be (message)
  }
}

}

My KP class has a method that configures the producer, in this case bootstrapserver: localhost, port 6666. And the send method receives the topic and the message

The test passes but in the console log I get this error

17:32:04.512 [kafka-producer-network-thread | producer-1] DEBUG org.apache.kafka.common.network.Selector - [Producer clientId=producer-1] Connection with localhost/127.0.0.1 disconnected
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.kafka.common.network.PlaintextTransportLayer.finishConnect(PlaintextTransportLayer.java:50)
at org.apache.kafka.common.network.KafkaChannel.finishConnect(KafkaChannel.java:106)
at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:444)
at org.apache.kafka.common.network.Selector.poll(Selector.java:398)
at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:460)
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.lang.Thread.run(Thread.java:748)

Any insights on why is this happening? When I changed the port on my KP.configure("localhost:12345" then the test really failed.

@manub
Copy link
Owner

manub commented Mar 5, 2018

if you try using EmbeddedKafka.start() and .stop() do you have the same result? I think the issue here is that there's an active connection while the server shuts down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants