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

Testing and Deployment

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

New Contributor
Posts: 4
Registered: ‎01-13-2012
My Device: 9780
My Carrier: O2
Accepted Solution

Connection stuck when connecting over BES/MDS

I have an application called MC Client (later referred as "client") which uses a socket connection in order to communicate with a Server, the Mobile Controller (later referred as "controller").
The connection is used to exchange signaling information for call control, instant messaging and presence information and uses the SIP protocol.
There are two ways how I can connect the Client to the Controller:
-Direct TCP (with a configured APN)

While first two modes work quite smooth we are facing some issues with the connection method over the MDS service.

The client itself uses the parameter deviceside=false to initiate the socket connection via the MDS server.
We did several traces on controller and client, and have the impression that the TCP stream is somehow blocked on the BES between the client and controller.

Following things we find out so far:
- The TCP connection handshake works very quickly. SYN,SYNACK,ACK handshake is performed always quick.
- The data channel itself seems to block / delay the data.
Initially the application did not send data to the socket, only after some data was sent initially from the controller side before. I worked around this by sending a single data packet into the stream with some dummy data "\r\n" from the controller to the client directly after the connection establishment.
That way a steam is usable by the client immediately, however after two messages the stream seems to block again.

I`m using Windows Server 2007 SP2 64 bit with BlackBerry® Enterprise Server Express and BlackBerry MDS Connection Service version:

Scenario Description:
[13:40:21.737] Client sends first data Packet "REGISTER"
- Packet is received on controller and replied with "401 Unauthorized" immediately after 15,8 msec (see packet trace)
[13:40:25.619] Client receives the "401 Unauthorized"
- Packet is delivered a bit late, but still in time (after 3,8 seconds)
[13:40:26.054] Client sends REGISTER with the authorization response
- the second packet never reaches the controller, the connection timed out

The BES server itself seems to be functional, since other applications like Email or the Rove SSH client seem to work well.

-Is there any way to influence the BES server how the packets for an MDS socket connection are forwarded? Is there some proper way to troubleshoot this on the BES server?
I look into the logs, the most information I can find there the a connection is opened and closed again.

Any hints?

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

Re: Connection stuck when connecting over BES/MDS

Is there a proxy server between the BES and your controller?  Could you give this sample application a try and let me know if it works.


Implement basic HTTP authentication

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: ‎01-13-2012
My Device: 9780
My Carrier: O2

Re: Connection stuck when connecting over BES/MDS

Hello Mark,

There is no proxy server, transparent proxy server or packet filter between the BES and the controller. The client is using a socket connection for this:

New Contributor
Posts: 4
Registered: ‎01-13-2012
My Device: 9780
My Carrier: O2

Re: Connection stuck when connecting over BES/MDS

I finaly found a solution for this.

We modified the client application to do a flush() after writing to the stream object.

Looks like that there is a mayor difference how the steam object of a socket behaves.

With direct TCP and WIFI all data is send imediately, while with the MDS connection everything gots queued for seconds until a flush() is made.


So remember: when using socket connection via MDS allways do flush when using time critical data communication.