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.

[BUG] java.lang.IllegalArgumentException: Invalid version for API key API_VERSIONS: 3

See original GitHub issue

Describe the bug Pulsar starts fine with Kafka protocol handler installed however I see error messages in logs.

13:12:48.091 [ForkJoinPool.commonPool-worker-3] INFO  org.apache.pulsar.broker.service.ServerCnx - [/127.0.0.1:56110] Created subscription on topic persistent://public/default/exclamation-input / public/default/exclamation
13:12:57.442 [pulsar-io-25-13] INFO  io.streamnative.pulsar.handlers.kop.KafkaRequestHandler - channel inactive [id: 0x17ea1bee, L:/127.0.0.1:9092 ! R:/127.0.0.1:56113]
13:12:57.443 [pulsar-io-25-13] INFO  io.streamnative.pulsar.handlers.kop.KafkaRequestHandler - close channel [id: 0x17ea1bee, L:/127.0.0.1:9092 ! R:/127.0.0.1:56113]
13:12:58.158 [pulsar-io-25-3] INFO  io.streamnative.pulsar.handlers.kop.KafkaRequestHandler - channel active: [id: 0x62a5187c, L:/127.0.0.1:9092 - R:/127.0.0.1:56128]
13:12:58.159 [pulsar-io-25-3] ERROR io.streamnative.pulsar.handlers.kop.KafkaCommandDecoder - error to get Response ByteBuf:
java.lang.IllegalArgumentException: Invalid version for API key API_VERSIONS: 3
	at org.apache.kafka.common.protocol.ApiKeys.schemaFor(ApiKeys.java:312) ~[?:?]
	at org.apache.kafka.common.protocol.ApiKeys.responseSchema(ApiKeys.java:286) ~[?:?]
	at org.apache.kafka.common.requests.ApiVersionsResponse.toStruct(ApiVersionsResponse.java:129) ~[?:?]
	at org.apache.kafka.common.requests.ResponseUtils.serializeResponse(ResponseUtils.java:40) ~[?:?]
	at io.streamnative.pulsar.handlers.kop.KafkaCommandDecoder.responseToByteBuf(KafkaCommandDecoder.java:112) ~[?:?]
	at io.streamnative.pulsar.handlers.kop.KafkaCommandDecoder.writeAndFlushResponseToClient(KafkaCommandDecoder.java:238) ~[?:?]
	at io.streamnative.pulsar.handlers.kop.KafkaCommandDecoder.lambda$channelRead$0(KafkaCommandDecoder.java:209) ~[?:?]
	at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:760) [?:1.8.0_121]
	at java.util.concurrent.CompletableFuture.uniWhenCompleteStage(CompletableFuture.java:778) [?:1.8.0_121]
	at java.util.concurrent.CompletableFuture.whenComplete(CompletableFuture.java:2140) [?:1.8.0_121]
	at io.streamnative.pulsar.handlers.kop.KafkaCommandDecoder.channelRead(KafkaCommandDecoder.java:208) [pulsar-protocol-handler-kafka-0.3.0-20200628-rc.nar-unpacked/:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [io.netty-netty-transport-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [io.netty-netty-transport-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [io.netty-netty-transport-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:321) [io.netty-netty-codec-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:295) [io.netty-netty-codec-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [io.netty-netty-transport-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [io.netty-netty-transport-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [io.netty-netty-transport-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) [io.netty-netty-transport-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [io.netty-netty-transport-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [io.netty-netty-transport-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) [io.netty-netty-transport-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [io.netty-netty-transport-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714) [io.netty-netty-transport-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) [io.netty-netty-transport-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) [io.netty-netty-transport-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) [io.netty-netty-transport-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) [io.netty-netty-common-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [io.netty-netty-common-4.1.48.Final.jar:4.1.48.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [io.netty-netty-common-4.1.48.Final.jar:4.1.48.Final]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]

To Reproduce Here is what I did using lates Pulsar and KoP:

  • Installed KoP using instructions in documentation.
  • Tried the Kafka consumer and produce test.
  • Here are relevant settings in broker.conf:
# Hostname or IP address the service binds on, default is 0.0.0.0.
bindAddress=0.0.0.0

# Hostname or IP address the service advertises to the outside world. If not set, the value of InetAddress.getLocalHost().getHostName() is used.
advertisedAddress=127.0.0.1

messagingProtocols=kafka
protocolHandlerDirectory=./protocol_handlers
allowAutoTopicCreationType=partitioned
# Use the same host value set for 'advertisedAddress' above (comma separated list is possible but must reflect advertisedAddress)
#listeners=PLAINTEXT://127.0.0.1:9092,PLAINTEXT://192.168.1.31:9092
listeners=PLAINTEXT://127.0.0.1:9092,SSL://127.0.0.1:9093

Expected behavior Expected it to just work

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
sijiecommented, Jul 9, 2020

@sido420 Yeah, I was following that Github Issue. It makes sense to us. We will prioritize an improvement for it.

0reactions
sijiecommented, Sep 3, 2020

This has been fixed by #176.

@sido420 Can you try it again?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error getting request for apiKey: 3 and apiVersion: 2 · Issue #441
Processor.run(SocketServer.scala:413) at java.lang. ... Caused by: java.lang.IllegalArgumentException: Invalid version for API key 3: 2 at ...
Read more >
Getting Invalid version for API key when writing a ...
Caused by: java.lang.IllegalArgumentException: Invalid version for API key 3: 2 at org.apache.kafka.common.protocol.ProtoUtils.
Read more >
Exception on apache kafka - Error getting request for apikey
I recently ran into this error (in a 3 node cluster) where 1 broker was started on version 1.0.0 and the other 2...
Read more >
Potential Fail on Join/Leave Operation when attempting to add ...
You see error similar to: 'Failed to Join Federation. ... java.lang.IllegalArgumentException: Invalid version for API key UPDATE_METADATA: 6.
Read more >
Kafka not listening on port 9092 - Teradata support
InvalidRequestException : Error getting request for apiKey: 3 and apiVersion: 5 ... Caused by: java.lang.IllegalArgumentException: Invalid version for API ...
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