Problems with FTP...

CARTHO

Member
Licensed User
Longtime User
Hi guys
I am hoping for your experience in one of my problem.
I have a program that is sending gps-positions every 30 seconds and also recieving small textfiles like 35 times during a 12 hour period. In the program I also need to send some answers back. The sending and recieving is done via ftp. The problem is that the GPRS is going down. Sometimes because I am going through a tunnel and sometimes because I don't know why. I tried different soultions to "keep alive", connect againg but the phone allways end up with a hanging situation - wich means I have to power off and start all over. Do you have any good ideas how to figure this one out?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can try switching to HTTP instead of FTP, it will give you more control and I believe that it will not hang when the connection is lost during communication. Another possible approach is to run another small program that will do the actual sending. You can then kill this process if it hangs (with agraham's Threading library).
 

CARTHO

Member
Licensed User
Longtime User
Problems with HTTP...

Thanks Erel for your answer.
I am looking into this right now and think you are right.
How ever I came across another problem:

When I try to Upload a file I recieve Response code 405 Method not allowed.
I recieve the code when hitting the row with Request.GetResponse.
The server is one of mine and I certainly do have write permissions...
Is there anything I am doing wrong here?

This is the code I use:

Sub UploadFile (UpFile, URL)
Response.New1
Request.New1(URL)

Request.Method = "PUT"
Writer.New1(Request.GetStream,True)

Dim Buffer(4096) As byte

FileOpen(c1,AppPath &"\" & UpFile,cRandom)
Reader.New1(c1,True) 'Reads the local file.
count = Reader.ReadBytes(buffer(),4096)
Do While count > 0
Writer.WriteBytes2(buffer(),0,count)
count = Reader.ReadBytes(buffer(),4096)
Loop
FileClose(c1)
Request.GetResponse
End Sub
 

CARTHO

Member
Licensed User
Longtime User
Actually NO.
But I changed the whole process to .asp-script and it works fine.
THANK YOU for quick answer and support and a perfect programming tool!
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…