Main Site Documentation

G120 based device - FtpWebRequest use


#1

Hi all,

I’m trowing some lines together to upload a log file to a FTP server but i get


    #### Exception System.IndexOutOfRangeException - 0xa9000000 (9) ####
    #### Message: 
    #### System.Net.FtpWebRequest::UploadThread [IP: 000d] ####
A first chance exception of type 'System.IndexOutOfRangeException' occurred in System.Ftp.dll
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in System.Ftp.dll
The program '[2] Micro Framework application: Managed' has exited with code 0 (0x0).

on Stream requestStream = request.GetRequestStream();


            FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://irc.emrol.com");
            request.Method = WebRequestMethods.Ftp.UploadFile;
            request.Credentials = new NetworkCredential("IRC", "*****");
            request.ServerPort = 21;
            request.UsePassive = false;
           
            FileStream sourceStream = new FileStream(@ "SD\boot.config", FileMode.Open, FileAccess.Read, FileShare.None, _buffersize);
            Stream requestStream = request.GetRequestStream(); 

Anny first idea’s ?


#2

The FTP Server is very buggy. I wouldn’t be surprised if FTP client is as well. :think:
1st I would change UsePassive to true (just to try if that works.
If that does not help, and you need FTP, I would get the sources and fix it (I did for the Server, it’s on codeshare).
https://www.ghielectronics.com/community/codeshare/entry/836

Alternatively you could use my CIFS client (also on codeshare) if a network share is an alternative for you.
https://www.ghielectronics.com/community/codeshare/entry/817
It should work quite well, but currently it supports plain text authentication only.


#3

So maybe best to download the porting kit and add the ftpclient from the source…
I have a look in the morning and see where i end up :whistle:


#4

Hi,
there are two ftp-client applications on CodeShare.
I did not test them yet.
https://www.ghielectronics.com/community/codeshare/entry/662

https://www.ghielectronics.com/community/codeshare/entry/751


#5

I had a quick look but both are using sockets and i believe sockets where a problem in 4.2? or not?

I have a deeper look in the morning but fixing ftpclient would be a benefit for the community i think.


#6

The FTPClient is working but indeed not really stable.
If i run my sample on a fixed network connection al seems to work fine but if i connect to a 3G Wlan i get a bunch socket errors.

I download the porting kit and had a look at the code but there is allot unfinished code…

I also had a look to the codeshare entry’s (these are 4.1) and i think extending the functionality in there is probably the shortest route…


#7

I do not see what the Problem should be with sockets in 4.2.
There is a Limit on parallel open sockets, but that’s partially in the GHI FW and was increased in later Versions.
I make really heavy use of Sockets with TCP connections on a G120 wit FW V4.2.11.1. No problem so far. May be a small memory leak, but I’m not sure if it comes from sockets or anything else.