URLConnection "application has gone off-line"

  1. 2 months ago

    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?

    Thanks!

  2. Has it ever happened to anyone that the application goes offline?
    Does anyone use URLConnection on a WebApp?

  3. Antonio R

    Sep 4 Pre-Release Testers, Xojo Pro, Third Party Store Europe (Italy)

    Gabriele, have you checked that your linux server has all the library needed by URLConnection?

  4. Greg O

    Sep 4 Xojo Inc scout.galaxy.barn

    @GabrieleMarchionni Self.sResult = Self.SendSync("POST", sURL, Me.iTimeOut)

    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.

  5. @Greg OLone with Send or SendSync the result is the same. I tried it now.

    @Antonio R what library need Linux? I published the entire Libs folder.

  6. I have another Xojo WebApp that runs on the same server, on another domain, and it works. But this one uses the GET method.

  7. Edited 2 months ago

    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.

  8. Greg O

    Sep 6 Xojo Inc scout.galaxy.barn

    @GabrieleMarchionni 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.

    What version of Xojo are you using?

  9. Xojo 2019 release 1.1

  10. Greg O

    Sep 8 Xojo Inc scout.galaxy.barn

    @GabrieleMarchionni Xojo 2019 release 1.1

    Ok, we’ll 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.

or Sign Up to reply!