smbj icon indicating copy to clipboard operation
smbj copied to clipboard

Connectivity fails randomly one of the IP mapped to the host name is In-correct /Not Active

Open fazeem84 opened this issue 4 years ago • 4 comments
trafficstars

Hi @hierynomus and @pepijnve, I am getting connection time out error randomly when I tried to connect share folder from My Java program. When debugging the code found out that while for mapping host name to IP InetAddress.getAllByName("hostname") is been used and it returns two IP address one of which is not getting connected and the other one works fine is there any way to try to connect the working IP if the other one fails to connect?

java.net.SocketTimeoutException: Connect timed out at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:546) at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597) at java.base/java.net.Socket.connect(Socket.java:648) at com.hierynomus.protocol.commons.socket.ProxySocketFactory.createSocket(ProxySocketFactory.java:87) at com.hierynomus.protocol.commons.socket.ProxySocketFactory.createSocket(ProxySocketFactory.java:63) at com.hierynomus.smbj.transport.tcp.direct.DirectTcpTransport.connect(DirectTcpTransport.java:88) at com.hierynomus.smbj.connection.Connection.connect(Connection.java:135) at com.hierynomus.smbj.SMBClient.getEstablishedOrConnect(SMBClient.java:108) at com.hierynomus.smbj.SMBClient.connect(SMBClient.java:79)

fazeem84 avatar Aug 17 '21 10:08 fazeem84

Can Anybody look into the issue?

fazeem84 avatar Aug 18 '21 14:08 fazeem84

Hi @fazeem84 I believe your hostname has 2 ip addresses (May be a load balancer or IP address is getting changed often(i.e Elastic IP)) your issue is similar to https://github.com/hierynomus/smbj/issues/644 Resolution

  1. Upgrade to SMBJ version 0.11.3
  2. do a try catch and remove the server from the SMBClient serverlist. Ex. smbclient.getServerList().unregister(<serverName>)
  3. Reconnect.

feel free to close this issue.

Thanks, R Ramarajan.

rokkakasu avatar Sep 06 '21 05:09 rokkakasu

hi @rokkakasu

I follow your recommendation, but still failed. Could you provide a snip code.

thanks

danielhasugian avatar Jun 25 '24 06:06 danielhasugian

I've tried to address this in #835, please see whether that works better

hierynomus avatar Jun 25 '24 11:06 hierynomus