PASV Mode Problem

Jun 10, 2013 at 7:18 PM
Hi,

I am trying to work in a passive mode, for reducing to the minimum client firewall issues.

On my LAN there are 2 computers:
  1. xLight ftp server.
    2 The ftp client, which is also the my developing machine.
When working on the LAN IP’s everything works well (in active mode though)

Now I am trying to simulate the case when a user connect to my server from the outside word so I am telling the client that the server host is my router WAN IP and port forwarding (configured my router) to my server LAN IP. I port forwarding port 21 and 50000 to 60000 for the data

I mange to create directory on the server though I get an exception at -> ostream = FTPConn.EndOpenWrite(ar)

Saying “No connection could be made because the target machine actively refused it”

Any idea what I am doing wrong?

Thanks,
Ziv
Coordinator
Jun 10, 2013 at 7:21 PM
Is the FTP server configured to use ports 50000 through 60000? Sounds like a classic firewall or server misconfiguration.
Jun 10, 2013 at 7:28 PM
Yes, I read the xLight manual and I guess I configured the router properly, and I also shutdown the firewall on the server machine… :(
Coordinator
Jun 10, 2013 at 7:31 PM
Log the transaction per Examples/Debug.cs and post in the forum. It will tell us the IP address and port number the server sent for the data channel. Could be a NAT issue with internal and external addresses.
Jun 10, 2013 at 7:38 PM
Sorry it might be a novice quetion, but how do i produce a log file and where is the log file placed (in the debug folder)?
Coordinator
Jun 10, 2013 at 7:41 PM
It's done with TraceListeners (System.Diagnostics.TraceListner) and the Debug example shows how to use trace listeners that are part of the .net framework or make your own. If you have a console application it's simple enough to:
FtpTrace.AddListener(new System.Diagnostics.ConsoleTraceListener())
To get the transaction log sent to the console window.
Jun 10, 2013 at 8:19 PM
i am not sure if it is what i wanted i here what i got:
3 difrent files:

"myTraceSource";Warning;0;"warning message";;5272;;;"2013-06-10T20:10:23.5889322Z";;
"myTraceSource";Error;0;"error message";;5272;;;"2013-06-10T20:10:23.6229342Z";;

"myTraceSource";Critical;0;"critical message";;5272;;;"2013-06-10T20:10:23.6249343Z";;

myTraceSource Warning: 0 : warning message
ProcessId=5272
DateTime=2013-06-10T20:10:23.5889322Z
Callstack=   at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at System.Diagnostics.TraceEventCache.get_Callstack()
at System.Diagnostics.TraceListener.WriteFooter(TraceEventCache eventCache)
at System.Diagnostics.TraceListener.TraceEvent(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, String message)
at System.Diagnostics.TraceSource.TraceEvent(TraceEventType eventType, Int32 id, String message)
at JumboMail.ServiceClient.Test.Program.Main(String[] args) in C:\Users\Ziv\Dropbox\ZivShareFolder\Programing\Production\JumboMail\Src\Client\Service\ServiceClient.Test\Program.cs:line 30
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
myTraceSource Error: 0 : error message
ProcessId=5272
DateTime=2013-06-10T20:10:23.6229342Z
Callstack=   at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at System.Diagnostics.TraceEventCache.get_Callstack()
at System.Diagnostics.TraceListener.WriteFooter(TraceEventCache eventCache)
at System.Diagnostics.TraceListener.TraceEvent(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, String message)
at System.Diagnostics.TraceSource.TraceEvent(TraceEventType eventType, Int32 id, String message)
at JumboMail.ServiceClient.Test.Program.Main(String[] args) in C:\Users\Ziv\Dropbox\ZivShareFolder\Programing\Production\JumboMail\Src\Client\Service\ServiceClient.Test\Program.cs:line 31
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
myTraceSource Critical: 0 : critical message
ProcessId=5272
DateTime=2013-06-10T20:10:23.6249343Z
Callstack=   at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at System.Diagnostics.TraceEventCache.get_Callstack()
at System.Diagnostics.TraceListener.WriteFooter(TraceEventCache eventCache)
at System.Diagnostics.TraceListener.TraceEvent(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, String message)
at System.Diagnostics.TraceSource.TraceEvent(TraceEventType eventType, Int32 id, String message)
at JumboMail.ServiceClient.Test.Program.Main(String[] args) in C:\Users\Ziv\Dropbox\ZivShareFolder\Programing\Production\JumboMail\Src\Client\Service\ServiceClient.Test\Program.cs:line 33
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>0</EventID><Type>3</Type>
<SubType Name="Warning">0</SubType><Level>4</Level><TimeCreated SystemTime="2013-06-10T20:10:23.5889322Z" />
<Source Name="myTraceSource" /><Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
<Execution ProcessName="JumboMail.ServiceClient.Test.vshost" ProcessID="5272" ThreadID="8" />
<Channel/><Computer>ZIV-PC</Computer></System><ApplicationData>warning message</ApplicationData>
</E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>0</EventID>
<Type>3</Type>
<SubType Name="Error">0</SubType><Level>2</Level><TimeCreated SystemTime="2013-06-10T20:10:23.6229342Z" />
<Source Name="myTraceSource" /><Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
<Execution ProcessName="JumboMail.ServiceClient.Test.vshost" ProcessID="5272" ThreadID="8" /><Channel/>
<Computer>ZIV-PC</Computer></System><ApplicationData>error message</ApplicationData>
</E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>0</EventID><Type>3</Type><SubType Name="Critical">0</SubType>
<Level>1</Level><TimeCreated SystemTime="2013-06-10T20:10:23.6249343Z" /><Source Name="myTraceSource" />
<Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
<Execution ProcessName="JumboMail.ServiceClient.Test.vshost" ProcessID="5272" ThreadID="8" />
<Channel/><Computer>ZIV-PC</Computer></System><ApplicationData>critical message</ApplicationData>
</E2ETraceEvent>
Jun 10, 2013 at 8:33 PM
i am using


<system.diagnostics>
<trace autoflush="true"/>
<sources>
  <source name="myTraceSource"
          switchName="mySwitch"
          switchType="System.Diagnostics.SourceSwitch" >
    <listeners>
      <clear/>
      <add name="evengloglistener"
        type="System.Diagnostics.EventLogTraceListener"
        initializeData="myApp" />
      <add name="delimitedListener"
        type="System.Diagnostics.DelimitedListTraceListener"

        initializeData="c:\Temp\Test\outfile.csv.txt"
        traceOutputOptions="ProcessId, DateTime" />
      <add name="textwriterListener"
        type="System.Diagnostics.TextWriterTraceListener"
        initializeData="c:\Temp\Test\outfile.txt"
        traceOutputOptions="ProcessId, DateTime, Callstack" />
      <add name="xmlListener"
        type="System.Diagnostics.XmlWriterTraceListener"
        initializeData="c:\Temp\Test\outfile.xml"
        traceOutputOptions="ProcessId, DateTime" />
    </listeners>
  </source>
</sources>
<switches>
  <add name="mySwitch" value="Warning" />
</switches>
</system.diagnostics>



with:

TraceSource ts = new TraceSource("myTraceSource");

// Writing out some events
ts.TraceEvent(TraceEventType.Warning, 0, "warning message");
ts.TraceEvent(TraceEventType.Error, 0, "error message");
ts.TraceEvent(TraceEventType.Information, 0, "information message");
ts.TraceEvent(TraceEventType.Critical, 0, "critical message");
Coordinator
Jun 10, 2013 at 8:34 PM
This is not what I wanted at all. Please read the Debugging Example that was included with the download and is in the source.
Jun 10, 2013 at 8:58 PM
Sorry it is midnight here :)...but i got it this time.

i will post the log output tomorrow!

Thanks a lot!!!

Ziv
Jun 10, 2013 at 9:08 PM
i managed to do it fast:

220 Xlight FTP Server 3.7 ready...
USER Admin
331 Password required for Admin
PASS <omitted>
230 Login OK
FEAT
211-Features supported
REST STREAM
EPRT
EPSV
SIZE
MDTM
MFMT
AUTH
PBSZ
PROT
MLST type*;size*;modify*;
MLSD
UTF8
211 End
OPTS UTF8 ON
200 OK, UTF8 ON.
QUIT
221 Good-Bye
220 Xlight FTP Server 3.7 ready...
USER Admin
331 Password required for Admin
PASS <omitted>
230 Login OK
FEAT
211-Features supported
REST STREAM
EPRT
EPSV
SIZE
MDTM
MFMT
AUTH
PBSZ
PROT
MLST type*;size*;modify*;
MLSD
UTF8
211 End
OPTS UTF8 ON
200 OK, UTF8 ON.
220 Xlight FTP Server 3.7 ready...
USER Admin
331 Password required for Admin
PASS <omitted>
230 Login OK
FEAT
211-Features supported
REST STREAM
EPRT
EPSV
SIZE
MDTM
MFMT
AUTH
PBSZ
PROT
MLST type*;size*;modify*;
MLSD
UTF8
211 End
OPTS UTF8 ON
200 OK, UTF8 ON.
PWD
257 "/"
CWD /
250 Directory successfully changed
TYPE I
200 Type set to I.
SIZE /Upload/1/wel.txt
550 Can't find file "wel.txt".
PASV
227 Entering Passive Mode (79,176,149,123,195,93)
Coordinator
Jun 10, 2013 at 9:25 PM
The problem has to be firewall or port forwarding related or the IP address in the 227 response at the end is wrong. The port number is 50013 which falls in the range you specified. Unless you have a reason that you want to use PASV over EPSV I recommend you stick with the default data channel type, AutoPassive, which automatically determines if it should use EPSV or PASV for passive transfers. The reason is because PASV doesn't support IPv6.
Jun 10, 2013 at 9:32 PM
i produced another run:

220 Xlight FTP Server 3.7 ready...
USER Admin
331 Password required for Admin
PASS <omitted>
230 Login OK
FEAT
211-Features supported
REST STREAM
EPRT
EPSV
SIZE
MDTM
MFMT
AUTH
PBSZ
PROT
MLST type*;size*;modify*;
MLSD
UTF8
211 End
OPTS UTF8 ON
200 OK, UTF8 ON.
QUIT
221 Good-Bye
220 Xlight FTP Server 3.7 ready...
USER Admin
331 Password required for Admin
PASS <omitted>
230 Login OK
FEAT
211-Features supported
REST STREAM
EPRT
EPSV
SIZE
MDTM
MFMT
AUTH
PBSZ
PROT
MLST type*;size*;modify*;
MLSD
UTF8
211 End
OPTS UTF8 ON
200 OK, UTF8 ON.
PWD
257 "/"
CWD /Upload/1
550 Can't change directory to "/Upload/1".
QUIT
221 Good-Bye
220 Xlight FTP Server 3.7 ready...
USER Admin
331 Password required for Admin
PASS <omitted>
230 Login OK
FEAT
211-Features supported
REST STREAM
EPRT
EPSV
SIZE
MDTM
MFMT
AUTH
PBSZ
PROT
MLST type*;size*;modify*;
MLSD
UTF8
211 End
OPTS UTF8 ON
200 OK, UTF8 ON.
PWD
257 "/"
CWD /Upload
250 Directory successfully changed
CWD /
250 Directory successfully changed
PWD
257 "/"
CWD /Upload/1
550 Can't change directory to "/Upload/1".
CreateDirectory("/Upload/1", True)
MKD /Upload/1
257 "/Upload/1/" directory created.
QUIT
221 Good-Bye
220 Xlight FTP Server 3.7 ready...
USER Admin
331 Password required for Admin
PASS <omitted>
230 Login OK
FEAT
211-Features supported
REST STREAM
EPRT
EPSV
SIZE
MDTM
MFMT
AUTH
PBSZ
PROT
MLST type*;size*;modify*;
MLSD
UTF8
211 End
OPTS UTF8 ON
200 OK, UTF8 ON.
QUIT
221 Good-Bye
220 Xlight FTP Server 3.7 ready...
USER Admin
331 Password required for Admin
PASS <omitted>
230 Login OK
FEAT
211-Features supported
REST STREAM
EPRT
EPSV
SIZE
MDTM
MFMT
AUTH
PBSZ
PROT
MLST type*;size*;modify*;
MLSD
UTF8
211 End
OPTS UTF8 ON
200 OK, UTF8 ON.
220 Xlight FTP Server 3.7 ready...
USER Admin
331 Password required for Admin
PASS <omitted>
230 Login OK
FEAT
211-Features supported
REST STREAM
EPRT
EPSV
SIZE
MDTM
MFMT
AUTH
PBSZ
PROT
MLST type*;size*;modify*;
MLSD
UTF8
211 End
OPTS UTF8 ON
200 OK, UTF8 ON.
PWD
257 "/"
CWD /
250 Directory successfully changed
TYPE I
200 Type set to I.
SIZE /Upload/1/wel.txt
550 Can't find file "wel.txt".
PASV
227 Entering Passive Mode (79,176,149,123,195,94)
Jun 10, 2013 at 9:42 PM
Maybe the reason is that I am sending from computer in my LAN to a computer also in my LAN but trying to simulate like I am out off my LAN be setting my client to connect to the router WAN IP?

I tried the default but i am getting an excpetion as well (i am not sure if it is the same exception though).
Jun 11, 2013 at 6:14 PM
I managed to solve the issue by configuring the router, setting my ftp server with the privilege of Default DMZ Server.

Thanks Author for your great willingness to help!!!
Coordinator
Jun 11, 2013 at 8:04 PM
Not a problem, glad you got it worked.