When I use URLConnection I get this error: “application has gone off-line”.
I created a clsCallHTTP class as super URLConnection.
The clsCallHTTP class has:
a property called iTimeOut or ftype Integer
a property called sResult of type String
a method called PostHTTP with this code inside:
Public Sub PostHTTP(sURL as string)
Self.sResult = ""
Self.sResult = Self.SendSync("POST", sURL, Me.iTimeOut)
End Sub
a Event Handlers ContentReceived with this code:
Sub ContentReceived(URL As String, HTTPStatus As Integer, content As String) Handles ContentReceived
self.sResult = content
End Sub
Then I have a WebDialog called wDoc which has a cHttp property of type clsCallHTTP.
In a button of this WebDialog I call my method in this way:
Dim URL as string = "https://www.domain.com/api/v0.3/SaveDocument"
Dim sDATA as string = "apiKey=myapikey&xml=myxmldata"
cHttp = New clsCallHTTP
cHttp.iTimeOut = 30
cHttp.RequestHeader("Content-Type") = "text/html;charset=UTF-8"
cHttp.SetRequestContent(sDATA, "application/x-www-form-urlencoded")
cHttp.PostHTTP(URL)
Do Until cHttp.sResult <> ""
'whait
Loop
Dim postResponse As String = ""
postResponse = cHttp.sResult
When I use it in local debugging, both Windows and MacOS, it works. When I compile it and publish it on my Linux server it doesn’t work.
The application works for all features, such as: reading and writing to MySQL, opening the Map, etc. But when I call the PostHTTP method of class clsCallHTTP the application go off-line.
Why in Debug work and compiled doesn’t work?
Have to enable something on my Linux server?
Don’t use SendSync. When you do this, your app locks up and waits for a response. If it takes long enough, the clients will disconnect and you’ll get the offline message. You should use the Send message and handle the responses asynchronously.
Ok, today I tried to my Linux Server, on the same domain folder, to execute the Send method and check the event to verify the result.
If I use GET method, it works perfectly.
If I use POST method, the application go off-line.
[quote=452983:@Gabriele Marchionni]Ok, today I tried to my Linux Server, on the same domain folder, to execute the Send method and check the event to verify the result.
If I use GET method, it works perfectly.
If I use POST method, the application go off-line.[/quote]
What version of Xojo are you using?
Ok, well it sounds like the post is crashing the app for some reason. Try creating a separate console app that just does the post and running that. You should get some output telling you if it crashed or an exception occurred.