roURLTransfer Timeout

Hi, I am making a request to an API from a task and the result is I am getting: a -28 as an error code and a message: “Connection timed out after 30005 milliseconds”.

I tried making the same request on Postman and it is working fine.

This is my while

While true
        msg = wait(0, m.port)

        If Type(msg) = "roUrlEvent"
            If msg.GetSourceIdentity() = request.GetIdentity()
                If msg.GetResponseCode() = 220
                    response = msg.GetString()

                    If response.len() <> 0
                        print ParseJson(response)
                        m.top.array = ParseJson(response)
                    Else
                        printDebug("Feed Failed")
                        m.top.statusCode = 102
                    End If
                Else
                    printError(msg)
                    printDebug("Feed Failed")
                    m.top.statusCode = msg.GetResponseCode()
                End If
            End If
        End If
    End While

How long does the http response really take - is it over 30 seconds?

“RokuNB” wrote:
How long does the http response really take - is it over 30 seconds?
Its way less than that

How is your API request structured? It might be a case that other parameters aren’t being set, or not being brought into your task.

For example

  request = CreateObject("roUrlTransfer")
  request.SetCertificatesFile("common:/certs/certificate.crt")
  request.SetUrl(myUrl)
  response = request.GetToString()

And the error you’re getting back, is it coming from the while loop, or is it a general error that’s being returned?

request = createObject(“roUrlTransfer”)
printDebug("Making Request to " + m.top.fetchURL)
‘Enable this for custom config files’
request.SetCertificatesFile(“common:/certs/certificate.crt”)
request.EnablePeerVerification(false)
request.SetUrl(m.top.fetchURL)
request.SetMessagePort(m.port)
request.AsyncGetToString()

That’s the request I am sending.
Its just a simple GET with no parameters

“victorCR” wrote:

request.AsyncGetToString()
You say you are doing this in a Task, so you can as well use the synchronous .getToString() - if you do that, does it work?
(i am not saying AsyncGetToString() has issues, rather troubleshooting “from simple to complex”, step by step)