You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Alex Xin <xi...@gmail.com> on 2010/06/27 17:17:50 UTC

Problems when working with Windows Explorer

Hi, folks

I'm trying to integrate FtpServer in my application. Now I have a problems
while my server is working with Windows Explorer client. I don't know how to
fix those bugs, so I post here hope someone could help me, thanks a lot!

My server runs on a Linux based device, and I have no root access, that
means I cannot bind to any TCP ports below 1024, of course I cannot use port
21 as usual. So I decide to use port 2211 to be my listen port. Then I use
following code fragment to change default passive port that will report to
client:

DataConnectionConfigurationFactory dataConnFactory = new
DataConnectionConfigurationFactory();
ListenerFactory factory = new ListenerFactory();

dataConnFactory.setPassiveAddress(factory.getServerAddress());
dataConnFactory.setPassiveExternalAddress(factory.getServerAddress());
dataConnFactory.setPassivePorts("4000-4199");
factory.setDataConnectionConfiguration(dataConnFactory.createDataConnectionConfiguration());

Now the problem is that this works great with most of FTP clients but failed
while working with Windows Explorer. The Windows will show me an error
message, please see attached screen snapshot for details.

the compatibility with Windows Explorer is very important because it's the
first choose for most of my users.

thanks a lot

Alex

Re: Problems when working with Windows Explorer

Posted by Niklas Gustavsson <ni...@protocol7.com>.
2010/6/28 Alex Xin <xi...@gmail.com>:
> For problem 2, Are there any classes or methods which I could use to set the
> charset?

Your first problem is that the FTP protocol does not declare the
charset used by the client. The RFC talks about ASCII and EBCDIC, and
then there is an extension that allows for using UTF-8. Since ASCII is
a subset of UTF-8, FtpServer assumes we can always use UTF-8. If a
client is using some other charset, your only option is to guess what
it might be.

Now, we set what charset we use in
org.apache.ftpserver.listener.nio.FtpServerProtocolCodecFactory and we
catch decoding errors in
org.apache.ftpserver.impl.DefaultFtpHandler.exceptionCaught(). We've
previously discussed having some form of fallback to a configurable
charset. However, we have never gotten around to implementing it.

/niklas

Re: Problems when working with Windows Explorer

Posted by Alex Xin <xi...@gmail.com>.
Hi, Niklas,

Thank you for your help. The first problem now solved. The root cause is
that ListenerFactory().getServerAddress() return 0.0.0.0. Maybe I use this
method in wrong way.

For problem 2, Are there any classes or methods which I could use to set the
charset?

thanks a lot

Alex

2010/6/28 Niklas Gustavsson <ni...@protocol7.com>

> 2010/6/27 Alex Xin <xi...@gmail.com>:
> > For the screenshot, please see it here:
> >
> > http://www.wifisharing.mobi/pic/ftp_error.png
>
> The server ask the client to open a passive connection to the IP
> 0.0.0.0 which will fail. Do you know why the server thinks this is a
> valid IP on your host? Also, you can try setting the external passive
> address to a valid IP on your host.
>
> > Also another problem that one of my users report:
> >
> > If the file name contains some special Chinese characters, it'll always
> fail
> > when working with Windows Explorer, but other clients like FlashFXP are
> OK.
> > For example, if we have a file named 中国近代史(美)徐中约.pdf, we'll get a server
> > error. The server will return 501 Invalid Character in command to client.
>
> FtpServer assumes that clients use UTF-8. It might be that the Windows
> client uses some other charset (like the one used on the client OS).
>
> /niklas
>

Re: Problems when working with Windows Explorer

Posted by Niklas Gustavsson <ni...@protocol7.com>.
2010/6/27 Alex Xin <xi...@gmail.com>:
> For the screenshot, please see it here:
>
> http://www.wifisharing.mobi/pic/ftp_error.png

The server ask the client to open a passive connection to the IP
0.0.0.0 which will fail. Do you know why the server thinks this is a
valid IP on your host? Also, you can try setting the external passive
address to a valid IP on your host.

> Also another problem that one of my users report:
>
> If the file name contains some special Chinese characters, it'll always fail
> when working with Windows Explorer, but other clients like FlashFXP are OK.
> For example, if we have a file named 中国近代史(美)徐中约.pdf, we'll get a server
> error. The server will return 501 Invalid Character in command to client.

FtpServer assumes that clients use UTF-8. It might be that the Windows
client uses some other charset (like the one used on the client OS).

/niklas

Re: Problems when working with Windows Explorer

Posted by Alex Xin <xi...@gmail.com>.
Hi Niklas,

thanks for reply.

I'm now developing an Android mobile phone application ,so I cannot get root
if I want my app to target random devices.

For the screenshot, please see it here:

http://www.wifisharing.mobi/pic/ftp_error.png

Also another problem that one of my users report:

If the file name contains some special Chinese characters, it'll always fail
when working with Windows Explorer, but other clients like FlashFXP are OK.
For example, if we have a file named 中国近代史(美)徐中约.pdf, we'll get a server
error. The server will return 501 Invalid Character in command to client.

thanks a lot.


On Sun, Jun 27, 2010 at 11:41 PM, Niklas Gustavsson <ni...@protocol7.com>wrote:

> On Sun, Jun 27, 2010 at 5:17 PM, Alex Xin <xi...@gmail.com> wrote:
> > The Windows will show me an error
> > message, please see attached screen snapshot for details.
>
> The screenshot did not make it to the mailing lists (attachments are
> removed). Please upload it somewhere where we can download it.
>
> Also, have a look at how you can run FtpServer on port 21:
> http://mina.apache.org/ftpserver/ftpserver-and-port-21-on-linux.html
>
> /niklas
>

Re: Problems when working with Windows Explorer

Posted by Niklas Gustavsson <ni...@protocol7.com>.
On Sun, Jun 27, 2010 at 5:17 PM, Alex Xin <xi...@gmail.com> wrote:
> The Windows will show me an error
> message, please see attached screen snapshot for details.

The screenshot did not make it to the mailing lists (attachments are
removed). Please upload it somewhere where we can download it.

Also, have a look at how you can run FtpServer on port 21:
http://mina.apache.org/ftpserver/ftpserver-and-port-21-on-linux.html

/niklas