You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Ted Gittinger <tg...@gmail.com> on 2011/07/29 22:58:22 UTC
[NET] FTPClientExample Hangs on Disconnect
I’ve been trying to use FTPClientExample.java to FTPS(FTP over SSL) to an
IBM mainframe. (From the 3.0.1 source.) It seems to work except the
‘ftp.disconnect()’
hangs and the thread never terminates. Here is the console output:
220-FTPSERV2 IBM FTP CS V1R11 at serverNameHere, 16:48:22 on 2011-07-27.
220-Welcome to the xyz FTP Server
220 Connection will close if idle for more than 5 minutes.
AUTH TLS
234 Security environment established - ready for negotiation
PBSZ 0
200 Protection buffer size accepted
PROT P
200 Data connection protection set to private
Connected serverAddressHere on serverPortHere
USER *******
331 Send password please.
PASS *******
230-******************************************************************
230-* Welcome JohnDoh to the XYZ system.
230-* It is Wed Jul 27 16:48:24 2011.
230-* Unauthorized use is prohibited. Usage may be subject to
230-* security testing and monitoring. Misuse is subject to criminal
230-* prosecution. There is no expectation of privacy except as
230-* provided by law.
230-******************************************************************
230 JOHNDOH is logged on. Working directory is "JOHNDOH.".
SYST
215 MVS is the operating system of this server. FTP Server is running on
z/OS.
PASV
227 Entering Passive Mode (xxx,xxx,xxx,xxx,x,xxx)
STOR 'SOMEFILE.NEW.EXAMPLE.TXT'
125 Storing data set SOMEFILE.NEW.EXAMPLE.TXT
250 Transfer completed successfully.
NOOP
200 OK
QUIT
221 Quit command received. Goodbye.
Note that the last reply from the server indicates a successful QUIT
command. However, the program never terminates.
Here's the debug information from the SSL socket which shows the QUIT and
then the attempted 'close_notify'. (For those that follow, I added
-Djavax.net.debug=all to the virtual machine arguments to get the debug
info.)
MAC: update
Padded plaintext before ENCRYPTION: len = 26
0000: 51 55 49 54 0d 0a 08 01 8d 8a c7 0a 02 d8 95 e9 QUIT............
0010: 6f ff c5 c2 ce ae 93 91 dd 5e o.........
main, WRITE: SSLv3 Application Data, length = 26
[Raw write]: length = 31
0000: 17 03 00 00 1a b3 6e 70 da b4 d0 b9 a2 49 58 2d ......np.....IX.
0010: 5a dd b5 3f 9d ea d1 66 ce 46 53 33 f8 a2 2a Z......f.FS3...
QUIT
[Raw read]: length = 5
0000: 17 03 00 00 39 ....9
[Raw read]: length = 57
0000: 43 aa e1 a9 9e 49 38 38 38 b0 fd 14 4c e0 eb d1 C....I888...L...
0010: 9c 5e 5b 83 9f c5 c8 30 ba 9e 91 54 14 ab da a8 .......0...T....
0020: f3 81 3d a2 46 22 a0 5c a7 30 30 32 66 3a 2a ee ....F....002f...
0030: 15 03 e2 30 35 89 78 ec 30 ...05.x.0
main, READ: SSLv3 Application Data, length = 57
Padded plaintext after DECRYPTION: len = 57
0000: 32 32 31 20 51 75 69 74 20 63 6f 6d 6d 61 6e 64 221.Quit.command
0010: 20 72 65 63 65 69 76 65 64 2e 20 47 6f 6f 64 62 .received..Goodb
0020: 79 65 2e 0d 0a 86 f4 3c 7d ca b9 de f4 e6 e3 20 ye..............
0030: 35 cf 2e 2a b3 c4 70 ae 71 5.....p.q
MAC: update
221 Quit command received. Goodbye.
3.0.1, b4 closing socket 6f0f6f0f[SSL_RSA_WITH_RC4_128_SHA:
Socket[addr=hostnamehere/ipaddresshere port=xxxx,localport=xxxx]]
main, called close()
main, called closeInternal(true)
main, SEND SSLv3 ALERT: warning, description = close_notify
MAC: update
Padded plaintext before ENCRYPTION: len = 22
0000: 01 00 1d 3a 7f 09 44 9c b7 9f 5c 2b 6c 71 d6 a1 ......D.....lq..
0010: 86 fc a3 f8 6a 51 ....jQ
main, WRITE: SSLv3 Alert, length = 22
[Raw write]: length = 27
0000: 15 03 00 00 16 e6 ad b4 00 9a c4 fc cd 30 b4 4d .............0.M
0010: a9 7a 82 2b a8 8a 4c 70 c4 f7 41 .z....Lp..A
main, waiting for close_notify or alert: state 5 <<<<<<<<<<< THE SSL SOCKET
IS WAITING FOR A REPLY FROM THE SERVER...
Notice that the SSL socket in my program is waiting for a 'close_notify'
response from the FTP server. It waits forever. I think this is because
the QUIT command closes the connection on the server.
So I commented out the 'logout(QUIT)' and ran the program again:
NO LOGOUT/QUIT HERE, IT'S COMMENTED OUT
3.0.1, b4 closing socket 71037103[SSL_RSA_WITH_RC4_128_SHA:
Socket[addr=addressGoesHere,port=portHere,localport=portHere]]
main, called close()
main, called closeInternal(true)
main, SEND SSLv3 ALERT: warning, description = close_notify
MAC: update
Padded plaintext before ENCRYPTION: len = 22
0000: 01 00 5b 7e 2e ac b5 87 21 0a 2b a6 6d cd 6b f1 ............m.k.
0010: b4 61 ad 5c 51 85 .a..Q.
main, WRITE: SSLv3 Alert, length = 22
[Raw write]: length = 27
0000: 15 03 00 00 16 76 e3 2b a6 dd a9 b2 30 b2 c6 ea .....v......0...
0010: a9 cb e8 75 6c 22 ed 46 e4 0e 13 ...ul..F...
main, waiting for close_notify or alert: state 5 <<<<<<<<<<<<<< HERE'S
WHERE THE HANG OCCURRED IN THE PREVIOUS RUN
[Raw read]: length = 5
0000: 15 03 00 00 16 .....
[Raw read]: length = 22
0000: e1 22 37 3a 99 bd 2f 2f 53 b1 a5 be a3 c5 7e bc ..7.....S.......
0010: 73 69 4b a9 a4 4b siK..K
main, READ: SSLv3 Alert, length = 22
Padded plaintext after DECRYPTION: len = 22
0000: 01 00 18 ca 28 9c fc c1 83 ba 20 3b a6 f8 30 36 ..............06
0010: fa 45 7e bc 4e d6 .E..N.
MAC: update
main, RECV SSLv3 ALERT: warning, close_notify <<<<<<<<<<<<<<<<<< HERE'S
WHERE THE FTP SERVER SENT A close_notify RESPONSE
main, called closeInternal(false)
main, close invoked again; state = 5
3.0.1, after closing socket
3.0.1, b4 closing closeable java.net.SocketInputStream@60636063
3.0.1, after closing closeable
3.0.1, b4 closing closeable java.net.SocketOutputStream@608f608f
3.0.1, after closing closeable
******** 3.0.1 exiting, error = 'false'
As you can see, commenting out the 'logout/QUIT' statement allowed the
program to terminate normally.
So should I simply disconnect from the server or should I QUIT and then
disconnect?
http://www.faqs.org/rfcs/rfc959.html
LOGOUT (QUIT)
This command terminates a USER and if file transfer is not
in progress, the server closes the control connection. If
file transfer is in progress, the connection will remain
open for result response and the server will then close it.
If the user-process is transferring files for several USERs
but does not wish to close and then reopen connections for
each, then the REIN command should be used instead of QUIT.
>>> Does this mean that QUIT closes the connection on the server? (It looks
like it should.)
An unexpected close on the control connection will cause the
server to take the effective action of an abort (ABOR) and a
logout (QUIT).
>>> Does this mean that disconnecting without QUIT will force the FTP
session to logout automatically?
Thanks for the help!