Re: .NET CF Socket are behaving very strangely

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I did the following tests:
Set the PASV range for the FTP server to 1027 - 3500.
My data connection (STOR or RETR) works (after PASV command) for ports
1027-1060. Then it stops working from 1061 onwards.

This made me conclude that the ports from 1061 onwards are blocked on
the firewall and/or router.

Now, I let the client try to connect in Thread (which sleeps for 5
secs and before retrying). I notice that no connection could be
established (I always get "server actively refused connection")
between client and FTP server. My client keeps on trying to connect
and eventually the FTP server reaches the port 3500, where it fails.
After that it reverts back to port 1027, 1028, ...

Here I notice that some of the ports that worked before (such as 1035,
1036...) no more works now. (I get the "server actively refused
connection" error). Then it again succeeds for a few ports before
failing till 3500 is reached and the process is repeated.

How do we explain that ports that worked during first trial fail
during second trial?

Thanks and Regards,
A

On Aug 18, 10:50 am, "@maram" <atmaram.mull...@xxxxxxxxx> wrote:
Hi Matt,

That's true. I asked the Network admin to check that out.

In the meantime, I analysed the FTP log and I notice that PASV
followed by STOR/RETR works for port 1034, 1035, 1036, fails for 1037.
works again for 1038....

This looks very strange?

I will get back here with results following the router/firewall
configurations.

Best regards,
Atmaram

On Aug 18, 5:34 am, Matt Evans <im.djma...@xxxxxxxxxxxxxx> wrote:

Have you restricted the range of ports that the ftp server will use in
passive mode? The problem may be that the router/firewall has a
limited range of ports forwarded to the ftp server that is different
to the range of ports the ftp server uses, therefore when it selects a
random one for the passive ftp connection it is sometime blocked by
the firewall.

Matt

On Aug 17, 7:39 pm, "@maram" <atmaram.mull...@xxxxxxxxx> wrote:

Matt,

Thanks for your response.

The FTP server is configured to accept 700 connections. I am using the
PASV (passive mode) and this is enabled on the server. The following
is the log for a successful and an unsuccessful upload. I get the
error "No connection could be made because the target machine actively
refused it" when I make the call Socket.connect(...).

Note the port I use to connect to the FTP server for upload is
calculated port = (value_returned_by_PASV[4] * 256) +
value_returned_by_PASV[5].

---------------------------------------------------------------------------­-------------------------------------------
CASE 1: successful upload
Aug 14 18:14:21 101054 Incoming connection request on interface
81.17.245.71
Aug 14 18:14:21 101054 Connection request accepted from 86.43.69.25
Aug 14 18:14:21 101054 USER TDSdemo
Aug 14 18:14:21 101054 331 User TDSdemo, password please
Aug 14 18:14:21 101054 PASS ***********
Aug 14 18:14:21 101054 230 Password Ok, User logged in
Aug 14 18:14:21 101054 PASV
Aug 14 18:14:21 101054 227 Entering Passive Mode (81,17,245,71,12,227)
Aug 14 18:14:22 101054 STOR /download/test.txt
Aug 14 18:14:22 101054 150 Opening data connection
Aug 14 18:14:23 101054 File transfer complete
Aug 14 18:14:23 101054 226 Transfer complete
Aug 14 18:14:23 101054 QUIT
Aug 14 18:14:23 101054 Connection terminated.
---------------------------------------------------------------------------­-------------------------------------------

---------------------------------------------------------------------------­-------------------------------------------
CASE 2: unsuccessful upload
Aug 14 18:17:38 101080 Incoming connection request on interface
81.17.245.71
Aug 14 18:17:38 101080 Connection request accepted from 86.43.69.25
Aug 14 18:17:38 101080 USER TDSdemo
Aug 14 18:17:38 101080 331 User TDSdemo, password please
Aug 14 18:17:38 101080 PASS ***********
Aug 14 18:17:38 101080 230 Password Ok, User logged in
Aug 14 18:17:38 101080 TYPE I
Aug 14 18:17:38 101080 200 Type Binary
Aug 14 18:17:38 101080 PASV
Aug 14 18:17:38 101080 227 Entering Passive Mode (81,17,245,71,12,246)
Aug 14 18:17:42 101080 QUIT
Aug 14 18:17:42 101080 Connection terminated.
---------------------------------------------------------------------------­-------------------------------------------

So far, I think this is a router-related problem. I'll read more about
this stuff and get back to you guys.

Thanks and Regards,
-A

On Aug 13, 11:56 pm, Matt Evans <im.djma...@xxxxxxxxxxxxxx> wrote:

When you hit this problem have you tried to connect to the ftp server
from some other computer? Are you hitting some sort of limit on the
server?

Are you making a new connection to the server for each file? And if
so, have you closed the connection to the ftp server properly? If you
haven't the connections may be waiting for a timeout and so you are
hitting a limit on the number of connections allowed to the ftp
server, before one times out and then your app can connect again with
a new connection.

Matt

On Aug 13, 8:48 pm, "@maram" <atmaram.mull...@xxxxxxxxx> wrote:

Hi all,

I have a .NET CF 2.0 (with SP2) app that needs to upload files
continuously to an FTP server. Now this seemed to work fine until I
did load tests on it, i.e, I tried to send files continuously without
stopping. The following gives the details. I am testing this via
ActiveSync and Emulator (VS2005, WM5.0).

In a thread, I am uploading files, one by one.
-If a file cannot be uploaded successfully, the thread sleeps for 5
secs and tries again.
-If a file is uploaded successfully, the next file is uploaded. There
is no sleep here.

The problem: after having uploaded like ~70 files, I am getting the
exception "No connection could be made because the target machine
actively refused it". Now the thread tries again, then sometimes it
succeeds.

How do I proceed to troubleshoot this? Any ideas?

The bottomline is I can connect to the server for like 5 mins (for the
consecutive non-stop transfer of 70 files. This means I can connect to
the server, IP address, username and password of FTP server are all
ok.

Thanking you for your time.

Best regards,
-A + puzzled- Hide quoted text -

- Show quoted text -

.



Relevant Pages

  • Microsoft FTP Server problem on W2K?
    ... We have a mainframe at work that FTPs file to a Microsoft W2K FTP server ... Microsoft FTP server can create both teh control and data ports for the ... connection; rather than requiring the mainframe to create the data port. ... the data connection MUST use the same IP address as the ...
    (microsoft.public.inetserver.iis.security)
  • Re: Microsoft FTP Server problem on W2K?
    ... Please note that both the Mainframe and Microsoft FTP Server is on same ... > connection; rather than requiring the mainframe to create the data port. ... the data connection MUST use the same IP address as ...
    (microsoft.public.inetserver.iis.security)
  • Re: Remote rebooting
    ... I'll bet you need to make a connection as administrator to the PC (using IPC$ as shown above) ... The machine is running under admin and I can add/modify/delete any files in any folder with either VNC or CuteFTP Pro. ... I can log in with CuteFTP PRO and do what I want with files etc. Seems odd to me that the ftp server is running yet apparently the Windows task manage isn't starting scheduled tasks. ... Even if I can't recover from this hang I need to setup a fool proof way to reboot this system. ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: PLEASE HEEEEEELLLLPPPP ME...
    ... Your problem is that the ports you have allowed are not the only ports FTP ... The first is the command connection which is the connection used ... > 10.1.0.1 is the IP address from my FTP server which is a computer placed ...
    (freebsd-net)
  • Re: .NET CF Socket are behaving very strangely
    ... The FTP server is configured to accept 700 connections. ... PASV and this is enabled on the server. ... Note the port I use to connect to the FTP server for upload is ... Aug 14 18:14:21 101054 Incoming connection request on interface ...
    (microsoft.public.pocketpc.developer)