2011-11-04 116 views
0

我們的應用程序「有時」超時,我們有一個Java客戶端連接到一個unix守護進程,由於某種原因它現在又一次拋出以下錯誤:SocketChannel - java.net.ConnectException:連接超時:連接

SocketException: Cannot establish connection to daemon 
java.net.ConnectException: Connection timed out: connect 
    at sun.nio.ch.Net.connect(Native Method) 
    at sun.nio.ch.SocketChannelImpl.connect(Unknown Source) 
    at java.nio.channels.SocketChannel.open(Unknown Source) 
    at .... 
    at java.lang.Thread.run(Unknown Source) 

此堆棧跟蹤是從下面的代碼:

try 
    { 
    InetSocketAddress inetAddress = new InetSocketAddress(InetAddress.getByName(serverName), serverPort); 
    socketChannel = SocketChannel.open(inetAddress); // <--- I think the problem is here 
    pipeSck = socketChannel.socket(); 

    } 
    catch (NoRouteToHostException e)//when the remote host cannot be reached or connection was refused 
    { 
    System.err.println("NoRouteToHostException: Cannot establish connection to daemon"); 
    e.printStackTrace(); 
    return 1; /* reply only with error */ 
    } 
    catch (SocketException e)//when the remote host cannot be reached or connection was refused 
    { 
    System.err.println("SocketException: Cannot establish connection to daemon"); 
    e.printStackTrace(); 
    return 1; /* reply only with error */ 
    } 

這個工程的99%的時間......任何想法,爲什麼我們得到的超時?

謝謝!

回答

1

「連接超時」意味着網絡暫時關閉(最有可能),或者如果它未在Windows上運行,則表明服務器的套接字積壓隊列已滿,可能發生此情況極端負載或拒絕服務攻擊。

+0

根據我的其他評論,積壓目前被設置爲10(並且已經大約15年)。我們的客戶現在有更多的用戶,所以它看起來終於達到了極限。 – Samah

+0

@Samah沒有辦法可以告訴實際的值沒有偷看內核,但平臺有其自己的最小值,並且它幾乎肯定會將該值提高到至少爲50. – EJP

+0

它運行Solaris 10,並根據此:http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/topic/com.ibm.websphere.express.doc/info/exp/ae/tprf_tunesolaris.html默認積壓是128.如果它默默地增加它到最低限度,我不知道那會是什麼。編輯:運行這個說「1」,但我不知道如果我看着正確的參數:ndd -get/dev/tcp tcp_conn_req_min' – Samah

0

我同意Crollster,但您也可以檢查是否在主機上有可能導致問題的防火牆。 UNIX軟管是否有防火牆?任何中間防火牆?本地局域網上的UNIX主機是什麼?如果不是,你有沒有網絡連接嗎?網絡很有趣。 :)

相關問題