[BUG] Protocol header verification problem

Open
#577 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
java

Research direction

Start with io.streamnative.pulsar.handlers.amqp.AmqpConnection.receiveProtocolHeader and the decoder path shown in the stack trace, especially AmqpBrokerDecoder.decodeBuffer. Reproduce the unsupported protocol initiation on the AMQP connection and compare the received header with the expected AMQP header. Done means the reported protocol-header failure is understood and the handler behaves correctly for the relevant input.

Written by the indexing model from the issue text.

Description

type/bug

Describe the bug

2022-06-29T00:56:24,383+0800 [pulsar-ph-amqp-35-1] ERROR io.streamnative.pulsar.handlers.amqp.AmqpConnection - Received unsupported protocol initiation for protocol version: 0-91 
org.apache.qpid.server.protocol.v0_8.transport.AMQProtocolHeaderException: Protocol header is not correct: Got ÿôÿý should be: AMQP
	at org.apache.qpid.server.protocol.v0_8.transport.ProtocolInitiation.checkVersion(ProtocolInitiation.java:172) ~[?:?]
	at io.streamnative.pulsar.handlers.amqp.AmqpConnection.receiveProtocolHeader(AmqpConnection.java:402) ~[?:?]
	at org.apache.qpid.server.protocol.v0_8.AMQDecoder.decode(AMQDecoder.java:125) ~[?:?]
	at org.apache.qpid.server.protocol.v0_8.ServerDecoder.decodeBuffer(ServerDecoder.java:44) ~[?:?]
	at io.streamnative.pulsar.handlers.amqp.AmqpBrokerDecoder.decodeBuffer(AmqpBrokerDecoder.java:62) ~[?:?]
	at io.streamnative.pulsar.handlers.amqp.AmqpConnection.channelRead(AmqpConnection.java:153) ~[?:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:995) ~[io.netty-netty-common-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[io.netty-netty-common-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[io.netty-netty-common-4.1.77.Final.jar:4.1.77.Final]
	at java.lang.Thread.run(Thread.java:833) [?:?]
2022-06-29T00:56:24,384+0800 [pulsar-ph-amqp-35-1] ERROR io.streamnative.pulsar.handlers.amqp.AmqpConnection - error while handle command:
java.lang.RuntimeException: org.apache.qpid.server.protocol.v0_8.transport.AMQProtocolHeaderException: Protocol header is not correct: Got ÿôÿý should be: AMQP
	at io.streamnative.pulsar.handlers.amqp.AmqpConnection.receiveProtocolHeader(AmqpConnection.java:416) ~[?:?]
	at org.apache.qpid.server.protocol.v0_8.AMQDecoder.decode(AMQDecoder.java:125) ~[?:?]
	at org.apache.qpid.server.protocol.v0_8.ServerDecoder.decodeBuffer(ServerDecoder.java:44) ~[?:?]
	at io.streamnative.pulsar.handlers.amqp.AmqpBrokerDecoder.decodeBuffer(AmqpBrokerDecoder.java:62) ~[?:?]
	at io.streamnative.pulsar.handlers.amqp.AmqpConnection.channelRead(AmqpConnection.java:153) ~[?:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496) ~[io.netty-netty-transport-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:995) ~[io.netty-netty-common-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[io.netty-netty-common-4.1.77.Final.jar:4.1.77.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[io.netty-netty-common-4.1.77.Final.jar:4.1.77.Final]
	at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: org.apache.qpid.server.protocol.v0_8.transport.AMQProtocolHeaderException: Protocol header is not correct: Got ÿôÿý should be: AMQP
	at org.apache.qpid.server.protocol.v0_8.transport.ProtocolInitiation.checkVersion(ProtocolInitiation.java:172) ~[?:?]
	at io.streamnative.pulsar.handlers.amqp.AmqpConnection.receiveProtocolHeader(AmqpConnection.java:402) ~[?:?]
	... 20 more
2022-06-29T00:56:24,384+0800 [pulsar-ph-amqp-35-1] INFO  io.streamnative.pulsar.handlers.amqp.AmqpConnection - close netty channel [id: 0x0b5b1b85, L:/127.0.0.1:5672 - R:/127.0.0.1:50566]

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Dominant language
Java
Stars
123
Forks
41
Avg merge
4h 43m
Merged PRs (30d)
4

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from streamnative/aop

All issues in streamnative/aop

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.