Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
LittleGruz
Posts: 12
Registered: ‎09-02-2013
My Device: Z10

HTTP request with libcurl fails across mobile network

I have an issue when using libcurl to send HTTP POST packets to an internal web server.

 

When I have a Z10 connected up to the WiFi, the response is fine and my program moves on.

But when I have the phone connected through the mobile network, the response is less than favourable and I get the "curl_easy_perform() failed" message in the console. I can, however, access the web server successfully with the browser on the phone through the same mobile network.

 

My libcurl code is practically identical to the libcurl POST example code.

 

curl_easy_setopt(curl, CURLOPT_URL, "webserver/submit_trip.php");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);

res = curl_easy_perform(curl);
if(res != CURLE_OK){
   setInformationText(QString("Web server is not responding properly. Unable to connect."));
   setSubmitEnabled(true);
   fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
}

 

What is the cause of this problem?

Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10

Re: HTTP request with libcurl fails across mobile network

What is the URL you are trying to access? http://webserver/submit_trip.php ?

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Contributor
LittleGruz
Posts: 12
Registered: ‎09-02-2013
My Device: Z10

Re: HTTP request with libcurl fails across mobile network

Yes, it is http://webserver/submit_trip.php.

I have now also tested it with explicity stating the protocol i.e. I added "http://" to the URL, which produced the same results.

Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10

Re: HTTP request with libcurl fails across mobile network

The host named "webserver" does not appear to be visible on the public internet so I don't really see how a mobile network could find and access it. Am I missing something?

 

Thanks

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Contributor
LittleGruz
Posts: 12
Registered: ‎09-02-2013
My Device: Z10

Re: HTTP request with libcurl fails across mobile network

The webserver is an internal server and is inaccessible to people outside the company. So through the "work" workspace the webserver is accessible through the browser, but for some reason not through the app (which is my problem).

Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10

Re: HTTP request with libcurl fails across mobile network

OK, I understand your issue now, thanks. Is your app installed in the work perimeter or the personal perimeter? You can access via the work browser because it's in the work perimeter and therefore can access the internal network.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Contributor
LittleGruz
Posts: 12
Registered: ‎09-02-2013
My Device: Z10

Re: HTTP request with libcurl fails across mobile network

The app is installed in the work perimeter (via BES).

Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10

Re: HTTP request with libcurl fails across mobile network

Thanks again. Do you have other apps that access internal servers via corporate wifi without issue?

 

Sounds like a possible BES IT Policy issue on the face of it.

 

I'll do some checking and get back to you.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Contributor
LittleGruz
Posts: 12
Registered: ‎09-02-2013
My Device: Z10

Re: HTTP request with libcurl fails across mobile network

No other app uses tries to access local webservers, let alone using libcurl to send data packets. So unfortunately there is nothing to test against in that regard.

 

Thanks for your efforts thus far.

Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10

Re: HTTP request with libcurl fails across mobile network

OK, thanks for the response.

 

I doubt this is a development issue as such..... just thinking out loud here! Open mind....

 

I'm in discussion with one of our BES experts at present to see what he can suggest.

 

The fact you can access using the work browser at least suggests BES configuration is OK.

 

If you use an IP address instead of host name in the URL, does that change anything?

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim