When I connect with smbj, error log shows:
...
I/c.h.s.c.Connection: Successfully authenticated user on 192.168.1.222, session is 4399187361905
I/c.h.s.s.Session: Logging off session 4399187361905 from host 192.168.1.222
I/c.h.s.t.PacketReader: Thread[Packet Reader for 192.168.1.222,5,main] stopped.
I/c.h.s.c.Connection: Closed connection to 192.168.1.222
I/c.h.s.s.Session: Connecting to \\192.168.1.222\pop on session 4399187361905
Immediately - without any delay. So the connection is closed immediately after it is opened and it will them crash if I try to list files...
Caused by: com.hierynomus.smbj.common.SMBRuntimeException: com.hierynomus.protocol.transport.TransportException: Cannot write SMB2_TREE_CONNECT with message id << 4 >> as transport is disconnected
Which seems obvious since there's no open connection.
A question, related to smbj, indicated there was a problem with the way that person used the try statement... I believe this is a similar case.
Within an AsyncTask, I have:
try (Connection connection = client.connect(serverName)) {
AuthenticationContext ac = new AuthenticationContext(username, password.toCharArray(), domain);
Session session = connection.authenticate(ac);
this.session = session;
return session;
} catch (IOException e) {
e.printStackTrace();
}
I'm certain there's a problem with the try-catch. Can someone please give a complete piece of code including the AsyncTask - as the smbj module github should have. I hope this will solve most issues for all users.
from How to properly use smbj to connect and list files on a samba share in Android java?
No comments:
Post a Comment