Android ofLoadURL() / ofHTTPRequest() not working


#1

Been trying and failing to get any request through on an Android device using the core ofLoadURL(“http://www.google.com”);

Manifest: Adding Access to the internet:

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
https://gist.github.com/danoli3/aa2a4ecc5609aac823c9 (Whole file).

App Code: (ofApp::setup)

ofHttpResponse response = ofLoadURL("http://www.google.com.au");

    if (200 == response.status)
    {
        std::string data = response.data.getText();
        ofLog(OF_LOG_NOTICE, data);
//        std::string result = response.data.getText();
    } else {
        ofLog(OF_LOG_FATAL_ERROR, ofToString(response.status));
    }

Currently tested on Google Nexus 4 (just for sanity, yes the device internet is on and working).

Console Error:

05-27 17:13:20.280: E/ofURLFileLoader(12342): handleRequest(): No message received
05-27 17:13:20.280: A/(12342): -1
This seems broken, however could be missing a critical step here.
Please advise or how can we fix? :D!

GitHub Issue:


#2

i think google wil always redirect to it’s https version, redirection should work too but perhaps you can try using the https url directly


#3

Think you might be right with that test link. However was happening with any link I was requesting (http)

I tested opening a example application with same workspace, and it worked. So no idea what is going on.
I tested the environment on another system build with Windows (all same files, build etc), using same eclipse project, and it works with problem project.

Something wrong with My OSX eclipse project… Such a weird one. Still can’t trace it…


#4

Solution!

So it is now working and I think I traced it down to a missing /libs/android-support-v4.jar in my project directory.

The .jar wasn’t uploaded to the git repo I am working off and yeah I think it was the cause of the issue.


#5

hi.

i experience a similar problem with e.g.: ofLoadURL(“https://google.com”) using AndroidStudio on current master.

i see the dependency to android-support-v4 in the gradle file:
compile 'com.android.support:support-v4:19.+'

getting the error from curl tells me:

from error-buffer:
"SSL certificate problem: unable to get local issuer certificate"

and for the returned CURLCode CURLE_SSL_CACERT:
"Peer certificate cannot be authenticated with given CA certificates"

to get first error-line, i added this to ofURLFileLoaderImpl::handleRequest:

char errorbuf[CURL_ERROR_SIZE];
curl_easy_setopt(curl.get(), CURLOPT_ERRORBUFFER, errorbuf);

any ideas how to make this work?