Closed cwkcyd closed 4 years ago
You might want to give a bit more background... I'm not sure what the question is...
url = smb://192.168.1.3/Public/
try {
val authenticationContext = AuthenticationContext("", "".toCharArray(), null)
smbClient.connect(ip)?.use { connection ->
connection.authenticate(authenticationContext )?.use session@{ session ->
if (isRoot) {
getSharedNameList(session)?.forEach {
Log.i(TAG, "shareName:$it")
}
return@session
}
val diskShare = session!!.connectShare(shareName) as DiskShare // Exception
diskShare?.use {
val list = diskShare.list(filePath)
list?.forEach {
Log.i(TAG, "fileName:${it.fileName}")
}
}
}
}
} catch (e: Exception) {
e.printStackTrace()
}
private fun getSharedNameList(session: Session): List<String>? {
val sharedNameList = ArrayList<String>()
val transport: RPCTransport = SMBTransportFactories.SRVSVC.getTransport(session)
val serverService = ServerService(transport)
serverService.shares0.forEach {
sharedNameList.add(it.netName)
}
return sharedNameList
}
Exception at val diskShare = session!!.connectShare(shareName) as DiskShare
debug log
java.net.SocketException: Broken pipe com.hierynomus.smbj.transport.tcp.direct.DirectTcpTransport.write(DirectTcpTransport.java:78) com.hierynomus.smbj.connection.Connection.send(Connection.java:277) com.hierynomus.smbj.session.Session.send(Session.java:285) com.hierynomus.smbj.session.Session.connectTree(Session.java:155) com.hierynomus.smbj.session.Session.connectShare(Session.java:144) com.cyd.smblib.controller.Smb2Process.getSamba2FileList(Smb2Process.kt:159) com.cyd.smblib.controller.Smb2Process.getSambaFiles(Smb2Process.kt:118)
07-23 10:24:44.920 I/SambaController( 1948): handleSamba2Files url = smb://192.168.1.3/Public/, username = null 07-23 10:24:44.940 W/System.err( 1948): com.hierynomus.mssmb2.SMBApiException: STATUS_ACCESS_DENIED (0xc0000022): Could not connect to \192.168.1.3\Public 07-23 10:24:44.945 W/System.err( 1948): at com.hierynomus.smbj.session.Session.connectTree(Session.java:173) 07-23 10:24:44.945 W/System.err( 1948): at com.hierynomus.smbj.session.Session.connectShare(Session.java:144) 07-23 10:24:44.945 W/System.err( 1948): at com.cyd.smblib.controller.SambaController.getSamba2FileList(SambaController.kt:273) 07-23 10:24:44.945 W/System.err( 1948): at com.cyd.smblib.controller.SambaController.requestLanDeviceFileList(SambaController.kt:118) 07-23 10:24:44.945 W/System.err( 1948): at com.cyd.smblib.SambaManager.callWithCallback(SambaManager.kt:67) 07-23 10:24:44.945 W/System.err( 1948): at com.cyd.launcher.AndroidManager$callWithCallback$1.run(AndroidManager.kt:118) 07-23 10:24:44.945 W/System.err( 1948): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 07-23 10:24:44.945 W/System.err( 1948): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 07-23 10:24:44.945 W/System.err( 1948): at java.lang.Thread.run(Thread.java:761)
individual machine reproduced (Non-self machine), using smbj-rpc to get the Shared file directory is normal. No problem with switching to SMB1.