FTP upload problem

Hi,

On the Q2686 system which I have designed, I am not able to upload files using FTP with two network operators. Following are various points in this context:

  1. Five network operators have been tried by me viz. Airtel, Idea, Reliance, Tata Docomo and Vodafone.
  2. I am able to download data with all these operators. So the GPRS details like activation, APN etc. seem to be OK.
  3. FTP upload is successful with Airtel, Idea and Tata. So the FTP details, active state, port 21 seem to be OK.
  4. FTP upload is not successful Reliance and Vodafone. I’m getting error 425 i.e. can’t open data connection.
  5. I have contacted the tech support of these operators. But frankly, I don’t expect any objective help from them.

I earnestly request some expert help on this forum.

Sincere thanks in advance.

Hi sanjeevk,

In some region with Vodafone, most of the port below 1024 are filtered.

Lets have a try by building your FTP connection on other port.

Regards,

Hi ToF,

Thank you very much for your prompt response. I would like to give more detailed description to you.

  1. With port 21, data channel is created. The file is just formed on the server. But no data is written in the file. The log is as follows:
    [WIP] new TCPCLIENT 0x18181018
    FTP session channel created
    Large file operation[=>FTP] “220 ProFTPD 1.3.2e Server (ProFTPD) [xxx.xx.xxx.xx]”
    [<=FTP] USER **********
    [=>FTP] “331 Password required for ***********”
    [<=FTP] PASS ****
    [=>FTP] “230 User ********** logged in”
    [<=FTP] TYPE I
    [=>FTP] “200 Type set to I”
    [WIP] new TCPSERVER 0x181814b8
    [<=FTP] PORT 1,39,231,234,4,10
    FTP data channel created[=>FTP] “200 PORT command successful”
    [<=FTP] STOR /httpdocs/filename.txt
    [=>FTP] “425 Unable to build data connection: Connection timed out”

  2. Upon your suggestion, I tried building FTP connection with various other port nos. viz. 1027, 10270, 15000, 25000, 35000, 45000, 55000, 65000 (admittedly, just taking chances). But with these port values, even the data channel is not opened. Only the session channel is created and I get WIP_CEV_ERROR event after about 1 minute. The file is not formed on the server.

I hope this gives more insight into the problem.

Hiya,

You need to post your code so we can see what’s going on. Remember to use the code tags when you post.

ciao, Dave

Try it with passive mode.

Hi Dave,

Thanks for your interest here. Following is the code. I am relatively new here (in terms of amount of time spent) and I am sorry I am not aware what you mean by code tagging. Just a gentle reminder that this code works fine with three network operators but doesn’t work with Vodafone and Reliance. I am in correspondence with these operators but no solution or suggestion has been given by them as yet.

void fileopr (){ // basic function to initiate ftp upload.  
	uplen = 0;
	senddebug ("\r\nLarge file operation", 'M', 5);
	if ((clienttest.schnl = wip_FTPCreateOpts (ftpserver, ftpupstart, NULL, WIP_COPT_USER, ftplogin, WIP_COPT_PASSWORD, ftppass,
				WIP_COPT_PEER_PORT, atoi (ftpprm1), // ftpprm1 stores port no. (set to 21)
				WIP_COPT_PASSIVE, (ftpstate == 'A') ? FALSE:TRUE, // ftpstate stores state (set to active)
				WIP_COPT_END)) == 0) senddebug ("\r\nCannot create FTP session channel", 'M', 5);
	else senddebug ("\r\nFTP session channel created", 'M', 5);
}


void ftpupstart (wip_event_t *ev, void *ctx){ // used for ftp upload
	switch (ev->kind){
		case WIP_CEV_OPEN:
			clienttest.dchnl = wip_putFileOpts (clienttest.schnl, filetoupload, updata, NULL, WIP_COPT_END); 
			senddebug ("\r\nFTP data channel created", 'M', 5); // filetoupload has been previously defined along with path on ftp server
			break;
		case WIP_CEV_PEER_CLOSE:
			closechannels ();
			break;
		case WIP_CEV_DONE:
			closechannels ();
			break;
		case WIP_CEV_ERROR:
			closechannels ();
			break;
		default:
			break;
	}
}


void updata (wip_event_t *ev, void *ctx){ // used for actually write (and in general, monitor) during ftp
	char upbuf[100];	
	int prelen;
	switch (ev->kind){
		case WIP_CEV_WRITE:
			if (uplen < flen){ // flen is size of data in dotabuf
				if ((prelen = wip_write (clienttest.dchnl, dotabuf+uplen, flen)) < 0) return; // dotabuf holds data to be uploaded to file
				uplen += prelen; // increment uplen by prelen
				sprintf (upbuf, "\r\nNo. of bytes written: %5d\r\n", prelen);
				senddebug (upbuf, 'M', 5);
			}
			if (uplen >= flen) wip_shutdown (clienttest.dchnl, FALSE, TRUE);
			break;
		case WIP_CEV_ERROR:
			closechannels ();
			break;
		case WIP_CEV_PEER_CLOSE:
			closechannels ();
			break;
		case WIP_CEV_DONE:
			closechannels ();
			break;
		default:
			break;
	}
}


void closechannels (){ // used for ftp or http
	wip_close (clienttest.dchnl); 		
	wip_close (clienttest.schnl); 
	senddebug ("\r\nFTP / HTTP file operation: Over", 'M', 5);
}


void senddebug (char *strn, char dest, char level){ // debug levels to be added afterwards.  presently, debuglevel is set 5
	if (dest == 'M' && level >= debuglevel) adl_atSendResponse (ADL_AT_RSP, strn); // destination M means serial port 1
}

Regards.

Sanjeev

Thank you for your reply. Setting passive mode was one of the first things I tried but it doesn’t work. Here’s the log when passive mode is set.

[WIP] new TCPCLIENT 0x181818f0
FTP session channel created[=>FTP] “220 ProFTPD 1.3.2e Server (ProFTPD) [...]”
[<=FTP] USER ***********
[=>FTP] "331 Password required for **********
[<=FTP] PASS ********
[=>FTP] “230 User *********** logged in”
[<=FTP] TYPE I
[=>FTP] “200 Type set to I”
[<=FTP] PASV
FTP data channel created[=>FTP] “227 Entering Passive Mode (,,,,193,64).”
[WIP] new TCPCLIENT 0x18183490

Nothing happens after this point.

Regards.

Sanjeev

Anybody having a kind heart, a big brain AND a solution to this problem? :wink:

Hello
Although this is a year later it may be useful to someone.
I have just had a similar problem and it was caused by the IP address returned in the set passive mode response being invalid:
[=>FTP] “227 Entering Passive Mode (x,x,x,x,198,245).” where x.x.x.x is a address unreachable by the modem.
If the FTP server replies with an internal network IP to a unit that on the internet then it is unlikely it will be able to connect to the opened port.
Chur