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

Web and WebWorks Development

Reply
Developer
Posts: 20
Registered: ‎08-24-2012
My Device: Curve 9300
My Carrier: Rogers
Accepted Solution

xmlhttprequest getting status 0 in Ripple, status 500 in Simulator

Hello,

 

I'm running into a problem that just won't go away.  The ultimate goal is to access REST services in my webworks app (for smartphone, not BB10 or PB), but I can't even get it working for downloading a web page (mostly).  I can actually grab www.google.ca fine from Ripple, but not the simulator (status=500).  And my own page served up from node.js gets status=0 with no response text in Ripple, and status=500 in the simulator.

 

I've confirmed network status in the simulator by using the browser to go to google and the page on my node server.  I've also confirmed that the server is sending the proper status (checked in Chrome).

 

When I hit the node server with my app, I can see it hit the server and return a respons, but when it gets to the app, the status is 0.

 

I have added <access subdomains="true" uri="*"/> to my config.xml.  My test method is pretty simple/standard.

 

 

function load(url) {
    var xmlhttp;
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }

    xmlhttp.onreadystatechange=function()
      {
// display the info on the page. displayInfo("registerInfo",xmlhttp.readyState + "-" + xmlhttp.status + "-" + xmlhttp.responseText); if (xmlhttp.readyState==4 && xmlhttp.status==200) { displayInfo("registerInfo",xmlhttp.responseText); } } xmlhttp.open('GET',url,true); xmlhttp.send(null); }

Any ideas?  I figure if I can get to google, I should be able to load my small test page.  And if I can get to it from the simulator browser, I don't see why the app would not be able to get to it.

Developer
Posts: 20
Registered: ‎08-24-2012
My Device: Curve 9300
My Carrier: Rogers

Re: xmlhttprequest getting status 0 in Ripple, status 500 in Simulator

Oh yeah, I'm also running chrome with --disable_web_security.
BlackBerry Development Advisor
Posts: 634
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: xmlhttprequest getting status 0 in Ripple, status 500 in Simulator

Hello,

 

Status 0 is usually what you get when you have some cross-domain security kicking in which is blocking your request.  I believe the flag for Chrome should be --disable-web-security (not --disable_web_security).

 

In regards to the simulator and the HTTP 500 (Internal Server Error) I don't have an answer off the top of my head.  I would suggest get it working in Chrome / Ripple first to make sure the request is actually valid to begin with.

 

Another thing I would recommend is to package the app with the -d flag, to enable debug mode and Web Inspector.  You'll be able to view the Network panel and see exactly what's happening with your requests on device, or simulator.  

 

Docs @ https://developer.blackberry.com/html5/documentation/web_inspector_overview_1553586_11.html

Developer
Posts: 20
Registered: ‎08-24-2012
My Device: Curve 9300
My Carrier: Rogers

Re: xmlhttprequest getting status 0 in Ripple, status 500 in Simulator

Yeah, I noticed the flag after I posted, and then it worked in Ripple, for a bit.  After a few successful GETs, it would stop at readystate=1, and then just start freezing when creating the XMLHttpRequest.  And simulator was still 500 in app, but fine in browser.

 

I compiled through Ripple and had the web inspector enabled.  Everything looked fine in the simulator, just didn't get a response back.

 

To add to the confusion, I tested on a Curve as well.  Google comes up fine. My own site gives a 504 (Connection refused) in app, but is fine in the BB browser.  Even tried changing the server to port 80 and no luck in app (browser still fine).

 

I'm pretty new to webworks dev, but I'm finding it frustrating that I'm getting 3 different results using a standard JavaScript object (not even BB API).

Developer
Posts: 20
Registered: ‎08-24-2012
My Device: Curve 9300
My Carrier: Rogers

Re: xmlhttprequest getting status 0 in Ripple, status 500 in Simulator

New Info!

 

If I run my webworks index.html through the Ripple web server/service, but with Ripple Disabled, then it works fine every time, for both local and remote pages.  As soon as I Enable Ripple, I start getting problems again.

BlackBerry Development Advisor
Posts: 634
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: xmlhttprequest getting status 0 in Ripple, status 500 in Simulator

In Ripple's settings, do you have "Cross Domain Proxy" enabled?

Developer
Posts: 20
Registered: ‎08-24-2012
My Device: Curve 9300
My Carrier: Rogers

Re: xmlhttprequest getting status 0 in Ripple, status 500 in Simulator

Yup.
Developer
Posts: 137
Registered: ‎12-22-2010
My Device: Curve 8520
My Carrier: Software Developer

Re: xmlhttprequest getting status 0 in Ripple, status 500 in Simulator

Did you try to disable the cross domain proxy? I had simular trouble.

Developer
Posts: 20
Registered: ‎08-24-2012
My Device: Curve 9300
My Carrier: Rogers

Re: xmlhttprequest getting status 0 in Ripple, status 500 in Simulator

OK, Disabling cross domain proxy helped in Ripple, however it still does not work in simulator or device (which is most important). No firewall to get in the way either. Will try my remote server later and see if that changes anything.
Developer
Posts: 119
Registered: ‎05-27-2010
My Device: 9900
My Carrier: Vodafone NL

Re: xmlhttprequest getting status 0 in Ripple, status 500 in Simulator

If you have doubke checked the access line

 

<access subdomains="true" uri="*"/>

 

And you are getting a 500 (which is way better dan anything below <400) also check if it makes any diference how you're connected with the simulator and/or real device test. (Wifi, GSM, etc..)

 

Maybe something goes wrong when the request goes through a specific network connectivity.

 

On a BB <10 you have many different trasnports that might be used and from 6.0 and higher, it's not always that apperant. But if your request goes through BIS-B and/or MDS those 'proxying' services might influence your request (they shouldn't but they could, escpecially if you're trying to connect to a local IP instead of an internet IP).

 

Could you share the get/post URL/URI you're using without compromising your security ?

 

@reumerd-- @BBDevGroupNL -- about me
If you like it, LIKE it ;-) ----- If it's solved, press solved ! --- If you solved it yourself, please let us know! We might have the same problem!