Hello all,
I have a few servers with isolated file systems. I need to pass some files between them for processing. These are the steps I used.
WepApp1: makes a HTTPSocket Post with base64 encoded data in the SetRequestContent to WebApp2
WepApp2: Captures data from the request.Entity field in the Handle URL event.
This is all fine and dandy for very small files, but when webapp1 tries to send a file that is 6mb, it takes 20 seconds for handle url to fire on webapp2.
WebApp1 and WebApp2 are running on the host. Is there any reason the data transfer is taking so long?
Thanks!
As a side note: I know that sending the same larger files using handleURL.request.write works wonderfully fast, but in this case WebApp1 is sending the data along with a request, I’m not asking for data.
first of all remember that when you call Post, the data is transferred from your app to an OS socket which sends the data to the server, and the speed of this operation can be affected by other processes.
Questions:
Are you using Xojo.Net.HttpSocket or the classic HTTPSocket?
Is webapp2 Standalone or CGI? SSL? IDE Version?
Thanks for the insights Greg, WebApp2 is a standalone web application built using Xojo IDE 2017R1.
I tested making the post from inside a websession and outside a websession. Same result. It takes around 20 seconds to transfer the file.
I remembered Webfiles. in the past I had used them to pass files around. I was able to use the following to achieve the speed you would expect from localhost server to localhost server.
WebApp1: Creates a webfile and passes the link in a post
WebApp2: Captures the url from the request.Entity field in the Handle URL event.
WebApp2: Makes a get request to WebApp1 to retrieve the data.
WebApp1
[code] Dim myWebFile as new webfile
myWebFile.MIMEType = “text/plain”
myWebFile.UseCompression = False
myWebFile.Data = txtData
Dim RESTSocket as New HTTPSocket
Dim strRESTJson as string = "{""DataUrl"":"""+EncodeBase64(str(app.port)+myWebFile.URL, 0)+"""}"
RESTSocket.SetRequestContent(strRESTJson,"text/plain")
Dim strRequest as string = "http://"+"webapp2"+"/rapidservices/Example/btnExample"
RESTSocket.Yield = true
Dim strResponce as string = RESTSocket.Post(strRequest,10)[/code]
WebApp2
Dim httpDown as new HTTPSocket
Dim strUrl as string =app.strUrlOfRequester+":"+DecodeBase64(txtScreenPage.Text,Encodings.UTF8)
Dim Data as text = httpDown.Get(strUrl,10).ConvertEncoding(encodings.UTF8).DefineEncoding(encodings.UTF8).totext
The Json is for a REST api builder by @Phillip Zedalis Called RapidServices. It works really well!