Skip to content

Commit 7c87652

Browse files
authored
Add exception handling for ProxyProtocolHandler and reduce log level for MQTTPreludeHandler,closes #167 (#168)
1 parent 93eb435 commit 7c87652

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

bifromq-mqtt/bifromq-mqtt-server/src/main/java/org/apache/bifromq/mqtt/handler/MQTTPreludeHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,14 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
199199
ctx.pipeline().remove(this);
200200
break;
201201
default:
202-
log.warn("Unsupported protocol version: {}", connectMessage.variableHeader().version());
202+
log.debug("Unsupported protocol version: {}", connectMessage.variableHeader().version());
203203
}
204204
}
205205

206206
@Override
207207
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
208208
// simple strategy: shutdown the channel directly
209-
log.warn("ctx: {}, cause:", ctx, cause);
209+
log.debug("ctx: {}, cause:", ctx, cause);
210210
eventCollector.report(getLocal(ChannelError.class).peerAddress(remoteAddr).cause(cause));
211211
ctx.channel().close();
212212
}

bifromq-mqtt/bifromq-mqtt-server/src/main/java/org/apache/bifromq/mqtt/handler/ProxyProtocolHandler.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@
2424
import io.netty.channel.ChannelInboundHandlerAdapter;
2525
import io.netty.channel.ChannelPipeline;
2626
import io.netty.handler.codec.haproxy.HAProxyMessage;
27+
import lombok.extern.slf4j.Slf4j;
28+
2729
import java.net.InetSocketAddress;
2830
import java.util.Iterator;
2931
import java.util.Map;
3032

3133
/**
3234
* This handler is used to parse the HAProxy protocol message and extract the real IP and port of the client.
3335
*/
36+
@Slf4j
3437
public class ProxyProtocolHandler extends ChannelInboundHandlerAdapter {
3538

3639
@Override
@@ -73,4 +76,10 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
7376
ctx.pipeline().remove(this);
7477
}
7578
}
79+
80+
@Override
81+
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
82+
log.debug("ctx: {}, cause:", ctx, cause);
83+
}
84+
7685
}

0 commit comments

Comments
 (0)