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

BlackBerry Push Development

Reply
New Developer
Posts: 11
Registered: ‎09-07-2009
My Device: Not Specified

Timeout in HttpPushDemo

We have an application based on HttpPushDemo, where the server sends several bulks of information to the client, using multiple "push" operations.

At some point, the "read" operation on the client teminates with an IOException, saying "Local connection timed out after ~ 120000". (we use RIM Push API, if it makes a difference)

Note that it is after some reads from the stream completed successfully, so it is not an issue of bad address.

1. Is the timeout on the device or on the BES?

2. Is there a way to increase it?

Thanks

 

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

Re: Timeout in HttpPushDemo

This should answer your question.

 

How To - Control the connection timeout for TCP connections through the BlackBerry MDS Connection Service

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/How_To_...

 

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Posts: 11
Registered: ‎09-07-2009
My Device: Not Specified

Re: Timeout in HttpPushDemo

Thanks for the link.

Hiwever, this document refers to a device that connects to a server. In our case - the device listens to connections, and the server is the one that performs the connect (like in the original HTTP Push demo program)

New Developer
Posts: 2
Registered: ‎09-02-2009
My Device: Not Specified

Re: Timeout in HttpPushDemo

I need to see your code to know exactly what the issue is, but I guess you are not using a StreamConnectionNotifier on the clinet side.

In the push demo, it looks like this:

 synchronized(this)  
                    {
                        // Open the connection once (or re-open after an IOException),  so we don't end up
                        // in a race condition, where a push is lost if it comes in before the connection
                        // is open again. We open the url with a parameter that indicates that we should
                        // always use MDS when attempting to connect.
                        _notify = (StreamConnectionNotifier)Connector.open(URL + ";deviceside=false");
                    }
                    
                    while (!_stop)
                    {
                        
                        // NOTE: the following will block until data is received.
                        stream = _notify.acceptAndOpen();
                        
                        try
                        {
                            InputStream input = stream.openInputStream();

                           ...

The idea is that the StreamConnectionNotifier doesn't open a connection, but actualy acts as a server, waiting for a push to come in. That way there is nothing to close with a timeout.

 

Hope what I said is understood and helpful.

Highlighted
New Developer
Posts: 11
Registered: ‎09-07-2009
My Device: Not Specified

Re: Timeout in HttpPushDemo

The code (which is based on the HTTP Push Demo) is doing exactly as you describe.

We usually see the problem when several connections are opened in parallel to the device (each one with its own stream and input stream, and running in its own thread). We create the thread after we open the InputStream, and let it read the data until reaching an "end of data". When reached, the InputStream and connection are closed, and the thread terminates.