question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Receiving "Connection Already Closed Error on Creating Producer"

See original GitHub issue

Expected behavior

I would expect the client to connect and build, or give a more useful error.

Actual behavior

When attempting to create the producer, I receive this error:

Exception in thread "main" org.apache.pulsar.client.api.PulsarClientException: Connection already closed
	at org.apache.pulsar.client.impl.ClientCnx.channelInactive(ClientCnx.java:169)
	at org.apache.pulsar.shade.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
	at org.apache.pulsar.shade.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
	at org.apache.pulsar.shade.io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224)
	at org.apache.pulsar.shade.io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:377)
	at org.apache.pulsar.shade.io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:342)
	at org.apache.pulsar.shade.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
	at org.apache.pulsar.shade.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
	at org.apache.pulsar.shade.io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224)
	at org.apache.pulsar.shade.io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1409)
	at org.apache.pulsar.shade.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
	at org.apache.pulsar.shade.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
	at org.apache.pulsar.shade.io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:927)
	at org.apache.pulsar.shade.io.netty.channel.AbstractChannel$AbstractUnsafe$8.run(AbstractChannel.java:822)
	at org.apache.pulsar.shade.io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
	at org.apache.pulsar.shade.io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
	at org.apache.pulsar.shade.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)
	at org.apache.pulsar.shade.io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
	at org.apache.pulsar.shade.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)

Steps to reproduce

We are not able to reproduce this issue with the python library. Here is the java code:

messageBus = PulsarClient.builder()
                .serviceUrl(messageBusUrl)
                .tlsTrustCertsFilePath("/Users/josh/Documents/myriadmobile/kernel/translator-mono/core/src/main/resources/pulsar-ca-cert.pem")
                .authentication("org.apache.pulsar.client.impl.auth.AuthenticationTls",
                        "tlsCertFile:/Users/josh/Documents/myriadmobile/kernel/translator-mono/core/src/main/resources/pulsar-public.pem,tlsKeyFile:/Users/josh/Documents/myriadmobile/kernel/translator-mono/core/src/main/resources/pulsar-private.pem")
                .build()

System configuration

This was originally encountered with 2.0.1-incubating (as referenced for the import in the java client import), and also persists in 2.1.0 and 2.1.1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
gurgen2727commented, Jul 16, 2019

I have the same issue running for Python version 2, pulsar version 2.4.0. Ubuntu 18.04.2 LTS (Bionic Beaver) running under Virtual Box in Windows 10

import pulsar client = pulsar.Client(‘pulsar://localhost:6650’) producer = client.create_producer(‘my-topic’) producer.send(“testing”) client.close()

2019-07-16 18:19:47.192 INFO ConnectionPool:72 | Created connection for pulsar://localhost:6650 2019-07-16 18:19:47.193 ERROR ClientConnection:360 | [ -> pulsar://localhost:6650] Failed to establish connection: Connection refused 2019-07-16 18:19:47.193 INFO ClientConnection:1297 | [ -> pulsar://localhost:6650] Connection closed 2019-07-16 18:19:47.193 ERROR ClientImpl:182 | Error Checking/Getting Partition Metadata while creating producer on persistent://public/default/my-topic – 5 2019-07-16 18:19:47.193 INFO ClientImpl:482 | Closing Pulsar client Traceback (most recent call last): producer = client.create_producer(‘my-topic’) File “/usr/local/lib/python2.7/dist-packages/pulsar/init.py”, line 476, in create_producer p._producer = self._client.create_producer(topic, conf) Exception: Pulsar error: ConnectError 2019-07-16 18:19:47.200 INFO ClientConnection:222 | [ -> pulsar://localhost:6650] Destroyed connection

changing ‘pulsar://localhost:6650’ -> ‘http://<local_ip>:6650’ doesn’t work either. I am really confused with this library.

3reactions
a1onzocommented, Oct 14, 2019

hi, is the issue above solved? i am confused with that error “Error Checking/Getting Partition Metadata while creating producer” too @gurgen2727

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - PulsarClientException: Connection already closed
Connection already closed. This means the connection is getting dropped after it connects but before it completes the handshake.
Read more >
What is the reason for "Connection already closed" error in ...
The open message platform does not allow access by default. If you need access, please submit a ticket to open.
Read more >
RabbitMQ tutorial - "Hello world!"
In this part of the tutorial we'll write two small programs in Python; a producer (sender) that sends a single message, and a...
Read more >
Error occurs when you send or receive an email message in ...
Lists various error messages that you may receive when you send or receive ... Method 2: Make sure that your Outlook email account...
Read more >
Kafka 3.3 Documentation
2.1 Producer API; 2.2 Consumer API; 2.3 Streams API; 2.4 Connect API ... Input is read from one or more topics in order...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found