|
25 | 25 | import io.netty.handler.timeout.ReadTimeoutHandler; |
26 | 26 | import java.io.IOException; |
27 | 27 | import java.net.InetSocketAddress; |
| 28 | +import java.net.SocketAddress; |
28 | 29 | import java.util.concurrent.TimeUnit; |
29 | 30 | import org.slf4j.Logger; |
30 | 31 | import org.slf4j.LoggerFactory; |
|
36 | 37 | import org.tron.common.overlay.discover.NodeStatistics; |
37 | 38 | import org.tron.common.overlay.message.*; |
38 | 39 | import org.tron.core.db.ByteArrayWrapper; |
| 40 | +import org.tron.core.exception.P2pException; |
39 | 41 | import org.tron.core.net.peer.PeerConnectionDelegate; |
40 | 42 | import org.tron.core.net.peer.TronHandler; |
41 | 43 |
|
@@ -152,14 +154,15 @@ public void disconnect(ReasonCode reason) { |
152 | 154 |
|
153 | 155 | public void processException(Throwable throwable){ |
154 | 156 | String errMsg = throwable.getMessage(); |
| 157 | + SocketAddress address = ctx.channel().remoteAddress(); |
155 | 158 | if (throwable instanceof ReadTimeoutException){ |
156 | | - logger.error("Read timeout, {}", ctx.channel().remoteAddress()); |
157 | | - }else if (errMsg != null && (errMsg.contains(MessageFactory.ERR_NO_SUCH_MSG) || |
158 | | - errMsg.contains(MessageFactory.ERR_PARSE_FAILED) || |
159 | | - errMsg.contains("Connection reset by peer"))){ |
160 | | - logger.error("{}, {}", errMsg, ctx.channel().remoteAddress()); |
| 159 | + logger.error("Read timeout, {}", address); |
| 160 | + }else if (errMsg != null && errMsg.contains("Connection reset by peer")){ |
| 161 | + logger.error("{}, {}", errMsg, address); |
| 162 | + }else if(throwable instanceof P2pException){ |
| 163 | + logger.error("type: {}, info: {}, {}", ((P2pException) throwable).getType(), errMsg, address); |
161 | 164 | }else { |
162 | | - logger.error("exception caught, {}", ctx.channel().remoteAddress(), throwable); |
| 165 | + logger.error("exception caught, {}", address, throwable); |
163 | 166 | } |
164 | 167 | close(); |
165 | 168 | } |
|
0 commit comments