2011-11-04 118 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主机是什么?如果不是,你有没有网络连接吗?网络很有趣。 :)

相关问题