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
New Contributor
guligo
Posts: 9
Registered: ‎03-23-2010
My Device: -
My Carrier: -

Re: AJAX Problem on BB Widget

[ Edited ]

Hi guys,

I think I have solved the problem. There was a tricky issue on Java server-side.

In my code requests were handled by Java servlet. Here is sample servlet class:

public class MyServlet extends HttpServlet {

@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setHeader(...);
resp.write("<xml>my superlarge xml goes here, etc...</xml>");
resp.setStatus(...);
}

}

It is not obvious, but this code (assuming that XML is very large - for example 12000 bytes) sends response to source (XHR object in Widget) before resp.write(...) operation is even completed. This is happening because content of response (on TCP/IP level) is sent to request source, split into data portions. These data portions are limited by buffer and the buffer size is a number resp.getBufferSize(). This is what I partly sorted out from here.

In my case resp.getBufferSize() == 8191. So every response with content more than 8191 bytes was split into 2 data portions. And BlackBerry XHR object stops processing in readyState 3 after it receives first data portion, although it is not completed content of response.

I solved this issue by increasing buffer size on Java server-side:

 

public class MyServlet extends HttpServlet {

@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setHeader(...);
String line = "<xml>my superlarge xml goes here, etc...</xml>";
resp.setBufferSize(line.length());
resp.write(line);
resp.setStatus(...);
}

}

I think this might be a solution for nrizz too. And don't you think that BlackBerry should be able to handle such situations? :smileyhappy:

 

Thanks for your help, guys!

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: AJAX Problem on BB Widget

Hi guligo,

 

Thanks for sticking with it and drilling down to the cause of the issue!!!

 

I'll send your results to our Browser Team to see if they can bring some more clarity around the topic.

 

Cheers

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Developer
nrizz
Posts: 26
Registered: ‎01-13-2010
My Device: 8330
My Carrier: Telus

Re: AJAX Problem on BB Widget

Hi guligo,

 

Great work figuring that out. I tried tweaking those settings as you did, and although my problem didn't go away, I found that it takes longer for the null to show up for the first time.

 

My setup is a bit different than you, I actually had to set the buffer size on the application server and on the jsp. Perhaps, I have another setting to find in order to get a fully reliable response. But it does seem like theres a corelation.

 

I was wondering how you were able to do the TCP analysis. Do you have some software that you would recommend?

 

Thanks

Please use plain text.
New Contributor
guligo
Posts: 9
Registered: ‎03-23-2010
My Device: -
My Carrier: -

Re: AJAX Problem on BB Widget

Hi nrizz,

 

I use Wireshark. However I am quite sure that there are better tools.

Please use plain text.
Developer
nrizz
Posts: 26
Registered: ‎01-13-2010
My Device: 8330
My Carrier: Telus

Re: AJAX Problem on BB Widget

Hi Tim,

 

Could we get an update on this. Was the Dev team able to reproduce what guligo has found? Is there a fix in the works?

 

Thanks

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: AJAX Problem on BB Widget

The testing team was able to re-produce the problem. They were able to get around it by using the work around suggested in this thread.

 

As far as a fix, I wouldn't imagine seeing a fix for this until 6.0

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: AJAX Problem on BB Widget

As a follow up update, we have also found that in later versions of the BlackBerry 5.0 OS, like the simulators included in the final RTM version of the BlackBerry Widget SDK and development tools, this issue no longer occurs.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Developer
nrizz
Posts: 26
Registered: ‎01-13-2010
My Device: 8330
My Carrier: Telus

Re: AJAX Problem on BB Widget

I gave my widget a test drive this morning with the new SDK/Simulators and all seems to working well, I've also noticed that the responses come back much faster. Thanks for looking into this.

 

Thanks

Please use plain text.
New Contributor
jcondeca
Posts: 2
Registered: ‎03-31-2011
My Device: Curve 3G - Torch
My Carrier: Tigo - Comcel

Re: AJAX Problem on BB Widget

Hi Guys,

 

I've been developing a webworks sample application that uses AJAX,but as mentionted here i receive every response as a null response, but this only happen in a BB Torch 9800 Os6 (both phone and sim), for another device (Curve 9300 Os6) the webworks app works correctly.

 

I've tried the solution posted here, and putting the server in the intranet and outside, but keep getting the same results. I'm going to try it in a curve 8520 with os5, to see what happens.

 

Can you please help me?

 

Thanks in advance.

 

Please use plain text.
New Contributor
jcondeca
Posts: 2
Registered: ‎03-31-2011
My Device: Curve 3G - Torch
My Carrier: Tigo - Comcel

Re: AJAX Problem on BB Widget

Hey Guys!

 

I've solved the problem, it was missing the content type "text/xml" in the servlet.

 

Thanks.

Please use plain text.