簡體   English   中英

Netty Server接受連接但不執行任何操作

[英]Netty Server accept connection and do nothing

我沒有找出此錯誤的原因“在發生以下異常后,我的Netty Server沒有處理任何消息。”

  org.jboss.netty.channel.SimpleChannelHandler - EXCEPTION, please implement com.kakapo.unity.handler.RegistrationHandler.exceptionCaught() for proper handling.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 223,384,284 milliseconds ago.  The last packet sent successfully to the server was 223,384,284 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
    at sun.reflect.GeneratedConstructorAccessor13.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3364)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1983)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2624)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2127)
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2293)
    at snaq.db.CachedPreparedStatement.executeQuery(CachedPreparedStatement.java:81)
    at com.kakapo.unity.handler.CustomIPFilterHandler.accept(CustomIPFilterHandler.java:46)
    at org.jboss.netty.handler.ipfilter.IpFilteringHandlerImpl.handleUpstream(IpFilteringHandlerImpl.java:118)
    at org.jboss.netty.handler.logging.LoggingHandler.handleUpstream(LoggingHandler.java:333)
    at org.jboss.netty.channel.Channels.fireChannelConnected(Channels.java:227)
    at org.jboss.netty.channel.socket.nio.NioWorker$RegisterTask.run(NioWorker.java:187)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.processRegisterTaskQueue(AbstractNioWorker.java:430)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:329)
    at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:35)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.net.SocketException: Connection timed out
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3345)
    ... 17 more

但是我已經將auto reconnect = true應用於我的JDBC。 並且也在使用OrderedMemoryAwareThreadPoolExecutor

ExecutionHandler channelExecutionHandler = new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(Runtime.getRuntime()
                .availableProcessors(), 0, 0)); 

我使用awaituninteruptable函數關閉通道。 喜歡

ctx.getChannel().write(new ErrMessage(e.getChannel().getRemoteAddress().toString()).getEncodedMessage())

這是否導致任何類型的無限循環活動。 現在的情況是服務器接受連接並且不處理任何類型的消息。我們有工作線程和上司。 但是日志記錄處理程序工作正常。 我正在使用snaq.db.connection池維護數據庫連接。

您似乎很直接地將MySQL連接與DriverManager.getConnection() 因此,您要么根本不關閉打開的連接,要么創建太多的連接,以致超出了MySQL服務器的限制。

在高度並行的環境中(並且肯定為此實現了Netty),我強烈建議使用數據庫連接池: c3p0commons-dbcp 使用正確的設置,您可以避免MySQL連接問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM