Unity<-->PhP<-->Ftp (FAIL)

As the Title says I’m haveing trouble with Unity comunicateing with php

This is the JS block of code

var wwwForm:WWWForm=new WWWForm();
	wwwForm.AddField("type",0);
	var www:WWW=new WWW(mainPHP,wwwForm);
	yield www;
	Debug.Log("Log1:"+www.text);
	currendDevID=www.text;
	if(currendDevID!="null")
		{
		var wwwForm2:WWWForm=new WWWForm();
		wwwForm2.AddField("type",1);
		wwwForm2.AddField("pathMeshes",localMeshPath);
		wwwForm2.AddField("pathTransforms",localTransformPath);
		wwwForm2.AddField("id",currendDevID);
		var www2:WWW=new WWW(mainPHP,wwwForm2);
		yield www2;
		Debug.Log("Log2:"+www2.text);
		if(www2.text=="1")
			{
			isBuilding=true;
			GetTypeObj();
			}
		}

This is the PHP function that I call

 function DownloadFiles()
	{
	
	$hostftp = '*******';
	$usr = '******';
	$pwd = '*****';
	$id=$_POST['id'];
	$queryOut=mysql_query ("SELECT id,ftpFolder FROM users WHERE id='$id'");
	$fetch=mysql_fetch_array($queryOut,MYSQL_BOTH);
	$conn_id = ftp_connect($hostftp, 21,10) or die ("Cannot connect to host");		
	ftp_login($conn_id, $usr, $pwd) or die("Cannot login");
	$link1=$fetch['ftpFolder']."Meshes.txt";
	$link2=$fetch['ftpFolder']."Transform.txt";
	$localLink1=$_POST['pathMeshes'];
	$localLink2=$_POST['pathTransforms'];
	ftp_get($conn_id,$localLink1,$link1,FTP_BINARY) or die("failed");
	ftp_get($conn_id,$localLink2,$link2,FTP_BINARY) or die("failed");
	echo "1";
	}

The problem is that for some reason the “www2” call isnt executed proprely because the php execution stops at the “ftp_login” with no errors no nothing …it just stops
This problem ocurred after I moved the php files to the ftp …it works fine locally

Does anyone have any idea what this is about?

potentially your host has an FTP timeout thats shorter than the time you need to get from 0 onto the FTP?
if thats the case then the solution wouldn’t work anyway as your webserver would die down if really being used.

Generally I doubt this is gonna work out because of the WWW timeout itself unless you can make this significantly faster so you return near immediately. Question is what you want to return there in the end and consider if you don’t have better ways to get there

Ok…But lets assume that FTP times out or the WWW,But how come they don’t time out when I do it locally …

I don’t actualy need to return anything but I don’t see how that is relevant

because your machine is likely not as slow as your webmachine and if your webhost and its ftp are in different location you also don’t have any php - ftp latency unlike your host

In general: you locally just don’t have latencies on any of the 4 connections that exist here (unity → php → mysql → php → ftp → php → unity)

Thanks…

Any Ideas how I could do this differently…What I’m trying to do is download some files from ftp

Seems to me if you just bypassed the www object and went straight to the FTPWebRequest object provided in .net you may get better results. :wink:

Once the file is confirmed and completed then talk to the php and have it deal with the sql if needed.

System.Web is basically never a solution unless the question is “how to not make it work”.
But its trivial to talk to FTP through System.Nets TCP socket too, so not much of a problem to go that path directly, after asking the PHP about the url to talk to for example

Thanks…I’ll try that hopefully I can fix this until the presentation from tomorrow xD