Hi,

I'm using the Commons FTP API to transfer a file to an FTP server. The FTP
server is located outside our corporate network and supports only active
FTP.

The connection to the FTP server went through, but it was throwing the
following exception when I tried to put a file or do a directory listing:

java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:168)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
        at java.io.FilterInputStream.read(FilterInputStream.java:66)
        at java.io.PushbackInputStream.read(PushbackInputStream.java:120)
        at
org.apache.commons.net.io.FromNetASCIIInputStream.__read(FromNetASCIIInputStream.java:74)
        at
org.apache.commons.net.io.FromNetASCIIInputStream.read(FromNetASCIIInputStream.java:169)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
        at
org.apache.commons.net.telnet.TelnetInputStream.__read(TelnetInputStream.java:104)
        at
org.apache.commons.net.telnet.TelnetInputStream.run(TelnetInputStream.java:520)
        at java.lang.Thread.run(Thread.java:536)

I traced through the code and found that the FTP connection is getting
reset after the client sends the PORT command. After sending the PORT
command, the API tries to get the server's response in the method
__getReply() in FTP.java. The above exception was thrown in the following
line inside __getReply():

String line = _controlInput.readLine();

I'm attaching the test program that I used and the log. The same code
works fine when I ran it from a Windows desktop. The Linux version is SuSE
Linux Enterprise Server 8.0. Could this be because of some firewall
blocking the inbound connection from the FTP server? If so how can I
verify it?

Any pointers on why this happens will be of great help.

Thanks,
Anoop

Attachment: FTPHandler.java
Description: java/

[EMAIL PROTECTED]:~/anoop-ftp2> java FTPHandler
The file name is test.pdf
READING FILE
BEFORE PUTTING
Inside getConnection
Main Map: {}
Connection Map: null
Inside createConnection
*Commons*: Inside __getReply()
*Commons*: before readLine()
*Commons*: After readLine()
*Commons*: length = 37
*Commons*: line.substring(0, 3);
*Commons*: Integer.parseInt(code);
*COmmons*: Inside sendCommand
*COmmons*: command USER
*COmmons*: args username
*Commons*: cobufferUSER username

*Commons*: After _controlOutput.write()
*Commons*: After _controlOutput.flush()
*Commons*: Before_getReply
*Commons*: Inside __getReply()
*Commons*: before readLine()
*Commons*: After readLine()
*Commons*: length = 37
*Commons*: line.substring(0, 3);
*Commons*: Integer.parseInt(code);
*Commons*: After _getReply
*COmmons*: Inside sendCommand
*COmmons*: command PASS
*COmmons*: args xxx
*Commons*: cobufferPASS xxxx

*Commons*: After _controlOutput.write()
*Commons*: After _controlOutput.flush()
*Commons*: Before_getReply
*Commons*: Inside __getReply()
*Commons*: before readLine()
*Commons*: After readLine()
*Commons*: length = 30
*Commons*: line.substring(0, 3);
*Commons*: Integer.parseInt(code);
*Commons*: After _getReply
*COmmons*: Inside sendCommand
*COmmons*: command TYPE
*COmmons*: args I
*Commons*: cobufferTYPE I

*Commons*: After _controlOutput.write()
*Commons*: After _controlOutput.flush()
*Commons*: Before_getReply
*Commons*: Inside __getReply()
*Commons*: before readLine()
*Commons*: After readLine()
*Commons*: length = 18
*Commons*: line.substring(0, 3);
*Commons*: Integer.parseInt(code);
*Commons*: After _getReply
*Commons*: Inside storeFile()
*Commons*: dataConnectionMode: 0
*Commons*: Inside _openDataConnection_
*Commons*: Inside if (__dataConnectionMode == ACTIVE_LOCAL_DATA
*Commons*: After server = _socketFactory_.createServerSocket(0, 1
*Commons: After IA
*Commons: Af6er lp
*COmmons*: Inside port()
*COmmons*: returning from port()
*COmmons*: Inside sendCommand
*COmmons*: command PORT
*COmmons*: args 10,140,45,66,211,165
*Commons*: cobufferPORT 10,140,45,66,211,165

*Commons*: After _controlOutput.write()
*Commons*: After _controlOutput.flush()
*Commons*: Before_getReply
*Commons*: Inside __getReply()
*Commons*: before readLine()
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:168)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
        at java.io.FilterInputStream.read(FilterInputStream.java:66)
        at java.io.PushbackInputStream.read(PushbackInputStream.java:120)
        at 
org.apache.commons.net.io.FromNetASCIIInputStream.__read(FromNetASCIIInputStream.java:74)
        at 
org.apache.commons.net.io.FromNetASCIIInputStream.read(FromNetASCIIInputStream.java:169)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
        at 
org.apache.commons.net.telnet.TelnetInputStream.__read(TelnetInputStream.java:104)
        at 
org.apache.commons.net.telnet.TelnetInputStream.run(TelnetInputStream.java:520)
        at java.lang.Thread.run(Thread.java:536)
*Commons*: Message is: Connection reset
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:168)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
        at java.io.FilterInputStream.read(FilterInputStream.java:66)
        at java.io.PushbackInputStream.read(PushbackInputStream.java:120)
        at 
org.apache.commons.net.io.FromNetASCIIInputStream.__read(FromNetASCIIInputStream.java:74)
        at 
org.apache.commons.net.io.FromNetASCIIInputStream.read(FromNetASCIIInputStream.java:169)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
        at 
org.apache.commons.net.telnet.TelnetInputStream.__read(TelnetInputStream.java:104)
        at 
org.apache.commons.net.telnet.TelnetInputStream.run(TelnetInputStream.java:520)
        at java.lang.Thread.run(Thread.java:536)
*COmmons*: Inside sendCommand
*COmmons*: command NOOP
*COmmons*: args null
*Commons*: cobufferNOOP

*Commons*: After _controlOutput.write()
FINISHED PUTTING and reply is : null
READING FILE
Inside getConnection
Connection Map: {}
Inside createConnection
*Commons*: Inside __getReply()
*Commons*: before readLine()
*Commons*: After readLine()
*Commons*: length = 37
*Commons*: line.substring(0, 3);
*Commons*: Integer.parseInt(code);
*COmmons*: Inside sendCommand
*COmmons*: command USER
*COmmons*: args username
*Commons*: cobufferUSER username

*Commons*: After _controlOutput.write()
*Commons*: After _controlOutput.flush()
*Commons*: Before_getReply
*Commons*: Inside __getReply()
*Commons*: before readLine()
*Commons*: After readLine()
*Commons*: length = 37
*Commons*: line.substring(0, 3);
*Commons*: Integer.parseInt(code);
*Commons*: After _getReply
*COmmons*: Inside sendCommand
*COmmons*: command PASS
*COmmons*: args xxxx
*Commons*: cobufferPASS xxxx

*Commons*: After _controlOutput.write()
*Commons*: After _controlOutput.flush()
*Commons*: Before_getReply
*Commons*: Inside __getReply()
*Commons*: before readLine()
*Commons*: After readLine()
*Commons*: length = 30
*Commons*: line.substring(0, 3);
*Commons*: Integer.parseInt(code);
*Commons*: After _getReply
*COmmons*: Inside sendCommand
*COmmons*: command TYPE
*COmmons*: args I
*Commons*: cobufferTYPE I

*Commons*: After _controlOutput.write()
*Commons*: After _controlOutput.flush()
*Commons*: Before_getReply
*Commons*: Inside __getReply()
*Commons*: before readLine()
*Commons*: After readLine()
*Commons*: length = 18
*Commons*: line.substring(0, 3);
*Commons*: Integer.parseInt(code);
*Commons*: After _getReply
Hostname: ftp.server.com
Port: -1
Usernameusername
Passwordxxxx
*COmmons*: Inside sendCommand
*COmmons*: command SYST
*COmmons*: args null
*Commons*: cobufferSYST

*Commons*: After _controlOutput.write()
*Commons*: After _controlOutput.flush()
*Commons*: Before_getReply
*Commons*: Inside __getReply()
*Commons*: before readLine()
*Commons*: After readLine()
*Commons*: length = 17
*Commons*: line.substring(0, 3);
*Commons*: Integer.parseInt(code);
*Commons*: After _getReply
*Commons*: Inside _openDataConnection_
*Commons*: Inside if (__dataConnectionMode == ACTIVE_LOCAL_DATA
*Commons*: After server = _socketFactory_.createServerSocket(0, 1
*Commons: After IA
*Commons: Af6er lp
*COmmons*: Inside port()
*COmmons*: returning from port()
*COmmons*: Inside sendCommand
*COmmons*: command PORT
*COmmons*: args 10,140,45,66,211,168
*Commons*: cobufferPORT 10,140,45,66,211,168

*Commons*: After _controlOutput.write()
*Commons*: After _controlOutput.flush()
*Commons*: Before_getReply
*Commons*: Inside __getReply()
*Commons*: before readLine()
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:168)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
        at java.io.FilterInputStream.read(FilterInputStream.java:66)
        at java.io.PushbackInputStream.read(PushbackInputStream.java:120)
        at 
org.apache.commons.net.io.FromNetASCIIInputStream.__read(FromNetASCIIInputStream.java:74)
        at 
org.apache.commons.net.io.FromNetASCIIInputStream.read(FromNetASCIIInputStream.java:169)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
        at 
org.apache.commons.net.telnet.TelnetInputStream.__read(TelnetInputStream.java:104)
        at 
org.apache.commons.net.telnet.TelnetInputStream.run(TelnetInputStream.java:520)
        at java.lang.Thread.run(Thread.java:536)
*Commons*: Message is: Connection reset
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:168)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
        at java.io.FilterInputStream.read(FilterInputStream.java:66)
        at java.io.PushbackInputStream.read(PushbackInputStream.java:120)
        at 
org.apache.commons.net.io.FromNetASCIIInputStream.__read(FromNetASCIIInputStream.java:74)
        at 
org.apache.commons.net.io.FromNetASCIIInputStream.read(FromNetASCIIInputStream.java:169)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
        at 
org.apache.commons.net.telnet.TelnetInputStream.__read(TelnetInputStream.java:104)
        at 
org.apache.commons.net.telnet.TelnetInputStream.run(TelnetInputStream.java:520)
        at java.lang.Thread.run(Thread.java:536)
*COmmons*: Inside sendCommand
*COmmons*: command NOOP
*COmmons*: args null
*Commons*: cobufferNOOP

*Commons*: After _controlOutput.write()
0
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to