Discussion:
[jcifs] More and more transport threads in blocking state
Stefan Neis
2014-08-07 08:29:41 UTC
Permalink
Hi JCIFS support team,



while we are investigating thread behavior on our application server we
stumbled over dozens of Transport threads in blocking state. It turned
out that they are belonging to the jCIFS framework on connecting to a
not existing SMB resource. To reproduce this I wrote a little piece of
code:



for (int i = 0; i < 100; i++) {

try {

SmbFile folder = new
SmbFile("smb://192.168.100.77/test");

folder.exists();

}

catch (SmbException e) {



}

}



My observations with the tool VisualVM are as follows. On the call
exists() a thread named Transport1 is created. After 30 seconds a
SmbException occurs:



jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.100.77

jcifs.util.transport.TransportException: Connection timeout



That is okay because the resource dos not exist. The next call to
exists() creates another Transport1 thread, while the first one is still
active for further 15 seconds. The second one is getting blocked by the
first thread. Because of the fact that the interval threads are getting
produced is shorter than the interval the threads are running, more and
more threads are in blocking state.

I tested it with jCIFS version 1.3.15 and 1.3.17.



The quick and dirty solution is to wait al least 15 seconds after every
thrown exception, but in my opinion it can't be the callers
responsibility to handle frameworks internal processes. And what if I
want to access the same resource from different places in my code?



Do you agree with this or am I doing something completely wrong?
Richard Heap
2014-08-07 15:13:08 UTC
Permalink
We find this all the time and as far as we can tell this is always
related to an incorrect DFS configuration in the domain controller (or
the DNS server).
If you are not using DFS, disable it in jcifs.
Post by Stefan Neis
Hi JCIFS support team,
while we are investigating thread behavior on our application server
we stumbled over dozens of Transport threads in blocking state. It
turned out that they are belonging to the jCIFS framework on
connecting to a not existing SMB resource. To reproduce this I wrote a
*for*(*int*i = 0; i < 100; i++) {
*try*{
SmbFile folder = *new*SmbFile("smb://192.168.100.77/test");
folder.exists();
}
*catch*(SmbException e) {
}
}
My observations with the tool VisualVM are as follows. On the call
exists() a thread named Transport1 is created. After 30 seconds a
jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.100.77
jcifs.util.transport.TransportException: Connection timeout
That is okay because the resource dos not exist. The next call to
exists() creates another Transport1 thread, while the first one is
still active for further 15 seconds. The second one is getting blocked
by the first thread. Because of the fact that the interval threads are
getting produced is shorter than the interval the threads are running,
more and more threads are in blocking state.
I tested it with jCIFS version 1.3.15 and 1.3.17.
The quick and dirty solution is to wait al least 15 seconds after
every thrown exception, but in my opinion it can't be the callers
responsibility to handle frameworks internal processes. And what if I
want to access the same resource from different places in my code?
Do you agree with this or am I doing something completely wrong?
Michael B Allen
2014-08-09 04:12:41 UTC
Permalink
Post by Stefan Neis
Hi JCIFS support team,
while we are investigating thread behavior on our application server we
stumbled over dozens of Transport threads in blocking state. It turned out
that they are belonging to the jCIFS framework on connecting to a not
for (int i = 0; i < 100; i++) {
try {
SmbFile folder = new SmbFile("smb://192.168.100.77/test");
folder.exists();
}
catch (SmbException e) {
}
}
My observations with the tool VisualVM are as follows. On the call exists()
a thread named Transport1 is created. After 30 seconds a SmbException
jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.100.77
jcifs.util.transport.TransportException: Connection timeout
That is okay because the resource dos not exist. The next call to exists()
creates another Transport1 thread, while the first one is still active for
further 15 seconds. The second one is getting blocked by the first thread.
Because of the fact that the interval threads are getting produced is
shorter than the interval the threads are running, more and more threads are
in blocking state.
I tested it with jCIFS version 1.3.15 and 1.3.17.
The quick and dirty solution is to wait al least 15 seconds after every
thrown exception, but in my opinion it can't be the callers responsibility
to handle frameworks internal processes. And what if I want to access the
same resource from different places in my code?
Do you agree with this or am I doing something completely wrong?
Hi Stefan,

I think that is happening because we use a separate Thread to read
from the socket (standard procedure in Java) and to connect and the
"transport" object used to represent the connection to the server is
shared. So the calling thread is timing out just before the socket
Thread.

More specifically, the following timeout properties and default values
in milliseconds govern JCIFS' behavior when trying to connect and
communicate with servers:

jcifs.smb.client.connTimeout = 35000
jcifs.smb.client.responseTimeout = 30000

Notice the difference of 5 seconds.

The connTimeout is passed to socket.connect() and instructs the JVM
how long it should wait for a server to successfully negotiate a TCP
connection. So with the default value of 35 seconds, if the server
does not exist (it does not respond to the SYN for example),
socket.connect() will throw a SocketException after 35 seconds.

The responseTimeout instructs JCIFS how long to wait for a meaningful
SMB response OR for the transport Thread to successfully return from
calling socket.connect(). So when trying to establish a connection
with a server that does not respond, it will timeout after 30 seconds.

For the sake of completeness, there is also jcifs.smb.client.soTimeout
= 35000 which is set using socket.setSoTimeout() immediately after
socket.connect() returns successfully and sets how long the JVM should
wait for ongoing TCP communication before throwing an exception. But
if the TCP connection is never successfully established, this property
should not be applicable.

You could try setting responseTimeout > connTimeout but I'm not sure
what effect that would have on overall logic. It might be a dubious
thing to do.

Otherwise, I'm not sure if something is "completely wrong". I would
have to think about that for a while. I could call interrupt() if the
responseTimeout is reached in Transport.connect(). But generally
calling Thread.interrupt() is considered bad. I don't think I would do
that unless I had no other choice really. And I don't think it would
be a good idea to just ditch the stuck transport and create a new one.
That would let your code continue but if it got stuck on another
server and another you would just exhaust VM and still not get
anywhere.

I don't think DFS is related to your particular issue but if you're
not using DFS it is a good idea to disable it by setting
jcifs.smb.client.dfs.disabled = true because JCIFS does not properly
retry other DFS nodes if DFS and / or file replication is
misconfigured in the domain. And perhaps more important there is a
deadlock bug in the DFS code.

If you try setting responseTimeout > connTimeout, let us know how it
goes. If it works well for you, maybe we should make it the default.

Mike
--
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/
Michael B Allen
2014-08-09 04:19:10 UTC
Permalink
Post by Michael B Allen
If you try setting responseTimeout > connTimeout, let us know how it
goes. If it works well for you, maybe we should make it the default.
Or we might just use connTimeout instead of responseTimeout where the
calling thread calls transport.connect() to kick off the transport
thread to call socket.connect(). Logically that makes more sense
anyway. I have added this to the TODO list for further investigation.

Mike
Stefan Neis
2014-08-12 11:57:30 UTC
Permalink
Hello Mike,

disabling DFS makes no difference. If I use the setting with
responseTimeout > connTimeout the threads do not block themselves
anymore, but then I got another anomaly.

The first call of exists() returns after a delay with the result of an
exception like before and the transport thread terminates.

jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.100.77
jcifs.util.transport.TransportException
java.net.SocketTimeoutException: connect timed out
at java.net.DualStackPlainSocketImpl.waitForConnect(Native
Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown
Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown
Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:264)
at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
at jcifs.util.transport.Transport.run(Transport.java:241)
at java.lang.Thread.run(Unknown Source)

at jcifs.util.transport.Transport.run(Transport.java:258)
at java.lang.Thread.run(Unknown Source)

But the second call in the loop throws a slightly different exception
and returns immediately without delay and with no transport thread
created.

jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.100.77
jcifs.util.transport.TransportException: Connection in error
jcifs.util.transport.TransportException
java.net.SocketTimeoutException: connect timed out
at java.net.DualStackPlainSocketImpl.waitForConnect(Native
Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown
Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown
Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:264)
at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
at jcifs.util.transport.Transport.run(Transport.java:241)
at java.lang.Thread.run(Unknown Source)

at jcifs.util.transport.Transport.run(Transport.java:258)
at java.lang.Thread.run(Unknown Source)

at jcifs.util.transport.Transport.connect(Transport.java:154)
at jcifs.smb.SmbTransport.connect(SmbTransport.java:307)
at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
at jcifs.smb.SmbFile.connect(SmbFile.java:954)
at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
at jcifs.smb.SmbFile.exists(SmbFile.java:1415)
...

The third call behaves like the first and the fourth like the second and
so on.

Stefan
André Warnier
2014-08-12 12:42:00 UTC
Permalink
Post by Stefan Neis
Hello Mike,
disabling DFS makes no difference. If I use the setting with
responseTimeout > connTimeout the threads do not block themselves
anymore, but then I got another anomaly.
The first call of exists() returns after a delay with the result of an
exception like before and the transport thread terminates.
jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.100.77
jcifs.util.transport.TransportException
java.net.SocketTimeoutException: connect timed out
at java.net.DualStackPlainSocketImpl.waitForConnect(Native
Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown
Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown
Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:264)
at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
at jcifs.util.transport.Transport.run(Transport.java:241)
at java.lang.Thread.run(Unknown Source)
at jcifs.util.transport.Transport.run(Transport.java:258)
at java.lang.Thread.run(Unknown Source)
But the second call in the loop throws a slightly different exception
and returns immediately without delay and with no transport thread
created.
jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.100.77
jcifs.util.transport.TransportException: Connection in error
jcifs.util.transport.TransportException
java.net.SocketTimeoutException: connect timed out
at java.net.DualStackPlainSocketImpl.waitForConnect(Native
Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown
Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown
Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:264)
at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
at jcifs.util.transport.Transport.run(Transport.java:241)
at java.lang.Thread.run(Unknown Source)
at jcifs.util.transport.Transport.run(Transport.java:258)
at java.lang.Thread.run(Unknown Source)
at jcifs.util.transport.Transport.connect(Transport.java:154)
at jcifs.smb.SmbTransport.connect(SmbTransport.java:307)
at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
at jcifs.smb.SmbFile.connect(SmbFile.java:954)
at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
at jcifs.smb.SmbFile.exists(SmbFile.java:1415)
...
The third call behaves like the first and the fourth like the second and
so on.
I have no idea of the code underlying this, but the above makes it look as if the second
attempt was trying to re-use the same outgoing socket as the first, and that socket was
still under the initial error condition. So the second call returns right away, without
even attempting a connection.
And to explain the behaviour of the 3rd attempt, maybe a look at the TCP/IP state diagram
in the case of a client connection timeout would provide a clue ?
(it may still be using the same socket, but by that time the error status is cleared ?)
Michael B Allen
2014-08-22 06:51:38 UTC
Permalink
Post by Stefan Neis
Hello Mike,
disabling DFS makes no difference. If I use the setting with
responseTimeout > connTimeout the threads do not block themselves
anymore, but then I got another anomaly.
The first call of exists() returns after a delay with the result of an
exception like before and the transport thread terminates.
jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.100.77
jcifs.util.transport.TransportException
java.net.SocketTimeoutException: connect timed out
at java.net.DualStackPlainSocketImpl.waitForConnect(Native
Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown
Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown
Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:264)
at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
at jcifs.util.transport.Transport.run(Transport.java:241)
at java.lang.Thread.run(Unknown Source)
at jcifs.util.transport.Transport.run(Transport.java:258)
at java.lang.Thread.run(Unknown Source)
But the second call in the loop throws a slightly different exception
and returns immediately without delay and with no transport thread
created.
jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.100.77
jcifs.util.transport.TransportException: Connection in error
jcifs.util.transport.TransportException
java.net.SocketTimeoutException: connect timed out
at java.net.DualStackPlainSocketImpl.waitForConnect(Native
Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown
Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown
Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:264)
at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
at jcifs.util.transport.Transport.run(Transport.java:241)
at java.lang.Thread.run(Unknown Source)
at jcifs.util.transport.Transport.run(Transport.java:258)
at java.lang.Thread.run(Unknown Source)
at jcifs.util.transport.Transport.connect(Transport.java:154)
at jcifs.smb.SmbTransport.connect(SmbTransport.java:307)
at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
at jcifs.smb.SmbFile.connect(SmbFile.java:954)
at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
at jcifs.smb.SmbFile.exists(SmbFile.java:1415)
...
The third call behaves like the first and the fourth like the second and
so on.
Hi Stefan,

I believe the "connection in error" condition will only occur if you
try to reuse the same transport after it just choked. Then, just in
case the server suddenly becomes alive at some point, it resets the
connection state. Thats why you then go back to "connect timed out". I
never really liked that behavior because it seems clumsey to ping-pong
between two different errors. But it's not obvious to me that anything
is logically wrong with this behavior. Think about it. If you try to
connect to a server and it chokes, why mindlessly try to connect to
the same server again? You should have some logic in your code that
catches the exception and just removes all targets on that server from
the list for the current scan.

So I would say that with some adjustment to your code as described
above and combined with using responseTimeout > connTimeout, that
should give you correct results.

If you're still not getting the desired result, please explain what
you think the correct results should be.

Mike
--
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/
Dev
2015-05-07 15:12:28 UTC
Permalink
Post by Michael B Allen
Post by Stefan Neis
Hello Mike,
disabling DFS makes no difference. If I use the setting with
responseTimeout > connTimeout the threads do not block themselves
anymore, but then I got another anomaly.
The first call of exists() returns after a delay with the result of an
exception like before and the transport thread terminates.
jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.100.77
jcifs.util.transport.TransportException
java.net.SocketTimeoutException: connect timed out
at java.net.DualStackPlainSocketImpl.waitForConnect(Native
Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown
Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown
Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:264)
at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
at jcifs.util.transport.Transport.run(Transport.java:241)
at java.lang.Thread.run(Unknown Source)
at jcifs.util.transport.Transport.run(Transport.java:258)
at java.lang.Thread.run(Unknown Source)
But the second call in the loop throws a slightly different exception
and returns immediately without delay and with no transport thread
created.
jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.100.77
jcifs.util.transport.TransportException: Connection in error
jcifs.util.transport.TransportException
java.net.SocketTimeoutException: connect timed out
at java.net.DualStackPlainSocketImpl.waitForConnect(Native
Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown
Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown
Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:264)
at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
at jcifs.util.transport.Transport.run(Transport.java:241)
at java.lang.Thread.run(Unknown Source)
at jcifs.util.transport.Transport.run(Transport.java:258)
at java.lang.Thread.run(Unknown Source)
at jcifs.util.transport.Transport.connect(Transport.java:154)
at jcifs.smb.SmbTransport.connect(SmbTransport.java:307)
at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
at jcifs.smb.SmbFile.connect(SmbFile.java:954)
at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
at jcifs.smb.SmbFile.exists(SmbFile.java:1415)
...
The third call behaves like the first and the fourth like the second and
so on.
Hi Stefan,
I believe the "connection in error" condition will only occur if you
try to reuse the same transport after it just choked. Then, just in
case the server suddenly becomes alive at some point, it resets the
connection state. Thats why you then go back to "connect timed out". I
never really liked that behavior because it seems clumsey to ping-pong
between two different errors. But it's not obvious to me that anything
is logically wrong with this behavior. Think about it. If you try to
connect to a server and it chokes, why mindlessly try to connect to
the same server again? You should have some logic in your code that
catches the exception and just removes all targets on that server from
the list for the current scan.
So I would say that with some adjustment to your code as described
above and combined with using responseTimeout > connTimeout, that
should give you correct results.
If you're still not getting the desired result, please explain what
you think the correct results should be.
Mike
Hi Michael,

I am getting the below exception when I try to use JCIFS-1.3.17.jar.
Please let me know what is the
resolution. Also can you let me know what are the ports that
JCIFS uses to connect to the destination
server? Is it something if we try to open the ports from source
to destination would help?

Thanks in advance.

osgi.wiring.package=*) -> [0]
jcifs.smb.SmbException: Failed to connect: 0.0.0.0(00)/10.12.212.41
jcifs.util.transport.TransportException: Connection timeout
at jcifs.util.transport.Transport.connect(Transport.java:174)
at jcifs.smb.SmbTransport.connect(SmbTransport.java:307)
at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
at jcifs.smb.SmbFile.connect(SmbFile.java:954)
at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
at jcifs.smb.SmbFile.open0(SmbFile.java:972)
at jcifs.smb.SmbFile.open(SmbFile.java:1006)
at jcifs.smb.SmbFileInputStream.<init>(SmbFileInputStream.java:73)
at jcifs.smb.SmbFileInputStream.<init>(SmbFileInputStream.java:65)
at

Thanks,
Dev
Michael B Allen
2015-05-13 23:42:03 UTC
Permalink
Post by Dev
Post by Michael B Allen
Hi Stefan,
I believe the "connection in error" condition will only occur if you
try to reuse the same transport after it just choked. Then, just in
case the server suddenly becomes alive at some point, it resets the
connection state. Thats why you then go back to "connect timed out". I
never really liked that behavior because it seems clumsey to ping-pong
between two different errors. But it's not obvious to me that anything
is logically wrong with this behavior. Think about it. If you try to
connect to a server and it chokes, why mindlessly try to connect to
the same server again? You should have some logic in your code that
catches the exception and just removes all targets on that server from
the list for the current scan.
So I would say that with some adjustment to your code as described
above and combined with using responseTimeout > connTimeout, that
should give you correct results.
If you're still not getting the desired result, please explain what
you think the correct results should be.
Mike
Hi Michael,
I am getting the below exception when I try to use JCIFS-1.3.17.jar.
Please let me know what is the
resolution.
Hi Dev,

Easy. Fix the network / other end to accept the connection.
Post by Dev
Also can you let me know what are the ports that
JCIFS uses to connect to the destination
server? Is it something if we try to open the ports from source
to destination would help?
Like a firewall problem? Certainly.

JCIFS uses TCP port 445 [1].

Mike

[1] Techincally JCIFS actually fails over to port 139 if 445 is not
available. But I don't know of any servers that only listen on 139.
Maybe some really old version of Samba. So port 139 can / should just
be ignored because if 445 doesn't work, 139 won't either.
--
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/
Post by Dev
osgi.wiring.package=*) -> [0]
jcifs.smb.SmbException: Failed to connect: 0.0.0.0(00)/10.12.212.41
jcifs.util.transport.TransportException: Connection timeout
at jcifs.util.transport.Transport.connect(Transport.java:174)
at jcifs.smb.SmbTransport.connect(SmbTransport.java:307)
at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
at jcifs.smb.SmbFile.connect(SmbFile.java:954)
at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
at jcifs.smb.SmbFile.open0(SmbFile.java:972)
at jcifs.smb.SmbFile.open(SmbFile.java:1006)
at jcifs.smb.SmbFileInputStream.<init>(SmbFileInputStream.java:73)
at jcifs.smb.SmbFileInputStream.<init>(SmbFileInputStream.java:65)
at
Venkatesh D
2015-05-14 20:41:17 UTC
Permalink
Thank you very much Mike! Its a firewall issue.
Post by Michael B Allen
Post by Dev
Post by Michael B Allen
Hi Stefan,
I believe the "connection in error" condition will only occur if you
try to reuse the same transport after it just choked. Then, just in
case the server suddenly becomes alive at some point, it resets the
connection state. Thats why you then go back to "connect timed out". I
never really liked that behavior because it seems clumsey to ping-pong
between two different errors. But it's not obvious to me that anything
is logically wrong with this behavior. Think about it. If you try to
connect to a server and it chokes, why mindlessly try to connect to
the same server again? You should have some logic in your code that
catches the exception and just removes all targets on that server from
the list for the current scan.
So I would say that with some adjustment to your code as described
above and combined with using responseTimeout > connTimeout, that
should give you correct results.
If you're still not getting the desired result, please explain what
you think the correct results should be.
Mike
Hi Michael,
I am getting the below exception when I try to use JCIFS-1.3.17.jar.
Please let me know what is the
resolution.
Hi Dev,
Easy. Fix the network / other end to accept the connection.
Post by Dev
Also can you let me know what are the ports that
JCIFS uses to connect to the destination
server? Is it something if we try to open the ports from source
to destination would help?
Like a firewall problem? Certainly.
JCIFS uses TCP port 445 [1].
Mike
[1] Techincally JCIFS actually fails over to port 139 if 445 is not
available. But I don't know of any servers that only listen on 139.
Maybe some really old version of Samba. So port 139 can / should just
be ignored because if 445 doesn't work, 139 won't either.
--
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/
Post by Dev
osgi.wiring.package=*) -> [0]
jcifs.smb.SmbException: Failed to connect: 0.0.0.0(00)/10.12.212.41
jcifs.util.transport.TransportException: Connection timeout
at jcifs.util.transport.Transport.connect(Transport.java:174)
at jcifs.smb.SmbTransport.connect(SmbTransport.java:307)
at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
at jcifs.smb.SmbFile.connect(SmbFile.java:954)
at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
at jcifs.smb.SmbFile.open0(SmbFile.java:972)
at jcifs.smb.SmbFile.open(SmbFile.java:1006)
at
jcifs.smb.SmbFileInputStream.<init>(SmbFileInputStream.java:73)
Post by Dev
at
jcifs.smb.SmbFileInputStream.<init>(SmbFileInputStream.java:65)
Post by Dev
at
Loading...