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

Java Development

Reply
Regular Contributor
Posts: 57
Registered: ‎09-22-2010
My Device: Not Specified
Accepted Solution

Exceeded the limit of number of bytes allowed per connection

Hi,

 

My scenario is like this (application targeted for OS 4.5):

I am creating a SocketConnection to a server wherefrom and whereto I send & receive JSON content. Connectivity is done either through MDS, BIS, Direct TCP based on entries from Service Book. Reading and writing is done without any problems (until some point) in two independent threads.

 

Using an MDS simulator, after a couple of minutes I get an exception, net.rim.device.cldc.io.ippp.SocketBaseIOException with message "Exceeded the limit of number of bytes allowed per connection!". Now, looking over DB-00623, this should not happen as I am making a SocketConnection through MDS (or I may not fully understand the first phrase). I have also seen other threads (this, this and this). Questions:

 

1. How to properly recognize this case at runtime? Since exception class is not available in Javadoc / JDK, seems to me the only way is to check class name in catch block.

2. How to properly recover? Simply re-establish connection? I am mentioning that in my case, modifying BES settings is not an option, because the application may be left to send & receive data even for days, so the limit is unknown.

 

Regards,

gunar

 

Regular Contributor
Posts: 57
Registered: ‎09-22-2010
My Device: Not Specified

Re: Exceeded the limit of number of bytes allowed per connection

Has anyone experienced this behavior and has some ideas?

BlackBerry Development Advisor
Posts: 15,809
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Exceeded the limit of number of bytes allowed per connection

Apologies if this is the article you were referring to... but the link you provided to the KB article is broken.

 

HTTP 413 Request Entity Too Large

http://supportforums.blackberry.com/t5/Java-Development/HTTP-413-Request-Entity-Too-Large/ta-p/44598...

 

Note that this limit also applies to socket connections.

 

The work around is to close and open a new connection if you are connecting through a BlackBerry Enterprise Server or the BlackBerry Internet Service. 

 

You could also limit your application to make use of direct TCP connections only, which have no limit.  But this isn't an option I recommend.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Regular Contributor
Posts: 57
Registered: ‎09-22-2010
My Device: Not Specified

Re: Exceeded the limit of number of bytes allowed per connection

Yes, that is the link I was reffering to. Thank you for provided answer. Do you have a comment to make on my first question - how to recognize this case?

Highlighted
Regular Contributor
Posts: 55
Registered: ‎08-26-2010
My Device: 8520

Re: Exceeded the limit of number of bytes allowed per connection

I have too encountered this problem, and I found out to be limited to 256KBytes per connection. I tested this limit on a handheld not in simulator. You can modify this values in the MDS simulator if you feel like but it doesn't help you on a real phone.

I had to transfer large files ( 5~10 MB) from a java web server to the phone using HttpConnection. Because I could only transfer 256Kb on one connection I opened more httpConnections in order to cover the file size. The data transfer could be done in parallel or sequential. In my case I used sequential transfer: open one connection , transfer data, open another connection, transfer data ,... . At the end of all transfer I appended all the received data into one file.

This limit of 256Kb per connection is applied only when you are using BES , BIS. I tested through wifi and I could transfer a 10mb file using only one connection.

I hope this helps you.

Regular Contributor
Posts: 57
Registered: ‎09-22-2010
My Device: Not Specified

Re: Exceeded the limit of number of bytes allowed per connection

Thanks, mihaizzav, for answering. I was aware of these, in my case the communication has no limit on the content transfered in and out. I know I have to re-connect while I encounter this exception, but how will I recognize it? The IOException class is of type SocketBaseIOException, but it's a friendly class, so nothing will prevent RIM from changing this class name in future API release and then I am in trouble ... So again, do you know a better way to recognize this case?

BlackBerry Development Advisor
Posts: 15,809
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Exceeded the limit of number of bytes allowed per connection

Instead of waiting for the exception, your application could keep track of the amount of data transmitted.  Then, if you are using a BES or BIS connection you could close the current connection and open a new one.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Regular Contributor
Posts: 57
Registered: ‎09-22-2010
My Device: Not Specified

Re: Exceeded the limit of number of bytes allowed per connection

OK, but how will application know this setting from BES / BIS? This setting might be set to 12K or 1.5M ... Is it possible to poll BES / BIS settings info ????

BlackBerry Development Advisor
Posts: 15,809
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Exceeded the limit of number of bytes allowed per connection

There isn't any way to poll for this setting.

 

BIS settings are the same for all users.  BES settings can range from 256KB to 1024KB.  However, very few people would have changed this setting from the default of 256KB.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
New Contributor
Posts: 4
Registered: ‎04-15-2011
My Device: torch
My Carrier: rogers

Re: Exceeded the limit of number of bytes allowed per connection

Hi Mark,

 

how to reopen the connection?

 

following is my code for downloading large file,

 

HttpConnection c = null;

try {

c = (HttpConnection) Connector.open(url + connectionParameters);

rc = c.getResponseCode();

if (rc == HttpConnection.HTTP_OK) {

s = c.openInputStream();

StringBuffer sb = new StringBuffer();

int ch = -1;  

long size = 0;

while ((ch = is.read()) != -1) {

sb.append((char) ch);

size++;

if(size>256000){

close();

// reopen connection ??? HOW 

                         c = (HttpConnection) Connector.open(url + connectionParameters);

}

else{

authRawData = sb.toString();

}

}

could you please share me some psudo code for this...

 

thanks