hierynomus / smbj

Server Message Block (SMB2, SMB3) implementation in Java
Other
705 stars 179 forks source link

Error while creating SMBJ Connection - java.util.concurrent.TimeoutException: Timeout expired #827

Open hkmudgal29 opened 3 months ago

hkmudgal29 commented 3 months ago

Hi, I am using below Java code using smbj-0.13.0 library on apache tomcat 10.1.23 and java version "17.0.10" 2024-01-16 LTS on RHEL 9.3 (Plow) VM. I tried telnet on host and port 445 from VM and it's working fine even ping is working fine - try (SMBClient smbClient = new SMBClient(config)) { log.info("smbClient initialized - "+smbClient); try (Connection connection = smbClient.connect(SMB_HOST)) { log.info("Connection created: "+connection); AuthenticationContext ac = new AuthenticationContext(smbUser, smbPassword.toCharArray(), null); try (Session session = connection.authenticate(ac)) { log.info("Session Created: "+session); try (DiskShare share = (DiskShare) session.connectShare(SMB_SHARE)) { ListObjectsV2Request listReq = ListObjectsV2Request.builder().bucket(BUCKET_NAME).prefix(date).build(); } catch (Exception e) { log.error("Exception while making DiskShare : "+e.getMessage()); } } catch (Exception e) { log.error("Exception while making Session : "+e.getMessage()); } } catch (Exception e) { log.error("Exception while Connection for SMB HOST: {}, Error: {}", SMB_HOST, e.getMessage()); } } catch (Exception e) { log.error("Exception while initializing SMBClient(), error: " + e.getMessage()); }

It's failing on line - try (Connection connection = smbClient.connect(SMB_HOST)) with following error -

2024-05-15T07:30:46.259Z INFO 39417 --- [nio-8080-exec-1] com.adobe.service.ComplianceService : smbClient initialized - com.hierynomus.smbj.SMBClient@4f54f699 2024-05-15T07:32:46.302Z INFO 39417 --- [nio-8080-exec-1] c.hierynomus.smbj.connection.Connection : Closed connection to indstore.corp.adobe.com 2024-05-15T07:32:46.303Z INFO 39417 --- [.corp.adobe.com] c.h.s.t.t.direct.DirectTcpPacketReader : Thread[Packet Reader for indstore.corp.adobe.com,5,main] stopped. 2024-05-15T07:32:46.310Z ERROR 39417 --- [nio-8080-exec-1] com.adobe.service.ComplianceService : Exception while Connection for SMB HOST: indstore.corp.adobe.com, Error: java.util.concurrent.ExecutionException: com.hierynomus.smbj.common.SMBRuntimeException: java.util.concurrent.TimeoutException: Timeout expired 2024-05-15T07:32:46.310Z INFO 39417 --- [nio-8080-exec-1] com.hierynomus.smbj.SMBClient : Going to close all remaining connections

However it's working on my laptop macos using same apache tomcat server and java version "17.0.6" 2023-01-17 LTS.

Can you help me to fix the issue ?