BlackBerry Java Application Development : Networking - Debugging with the MDS simulator

6/30/2012 3:25:29 PM
The MDS simulator is an important piece of the debugging puzzle. So far, you have used only the Direct TCP/IP transport in the examples that you've done. While this is the easiest to do during development and testing, it is not necessarily the best transport to use in production. It's good to use in testing because there are fewer components involved and therefore, fewer points of failure. If you can't get it to work by using Direct TCP/IP in the simulator, you most likely won't be able to get it to work using any other transports.

If you recall, using the MDS transport provides an encrypted and secure tunnel for the networking communication to travel through between your handheld to your server in your office. The MDS simulator provides that same secured tunnel between the simulator and your local machine so that you can test applications that use that tunnel.

The browser application on the simulator uses the MDS transport, which is why you can't use the browser on the simulator to test out your connectivity and which is why you haven't been able to use the browser so far. Once you start the MDS simulator though, you can use the browser application just fine.

The MDS Simulator is not started automatically though, so you need to do one of two things to start using it-you can either launch the simulator manually or you can modify debugging configurations in Eclipse so that it is configured to start automatically.

The MDS simulator does come with the SDK that is installed with Eclipse, but there is no icon on the start menu to launch it. In order to launch it by hand you must navigate to the install path and double-click a file called run.bat located in the MDS directory of your install directory. If you choose the default options when you installed the Eclipse Full Package, then that directory will be C:\Program Files\Eclipse\plugins\net.rim.eide.componentpack4.5.0_4.5.0.16\components\MDS.

The second option is to modify the debug configurations in Eclipse. To do this, open the configuration manager dialog by navigating to Run | Debug Configurations. When the dialog is shown select the Simulator tab.

The selected profile should be Default Simulator in the drop list and all of the options in the property page are disabled.

In order to enable the MDS simulator you must first select another profile from the profile list. Once another profile has been selected the fields in the dialog are enabled and you can place a checkmark into the field labeled Launch Mobile Data Systems Connection Service (MDS-CS) with simulator. Finally, click on Close to apply the changes. Alternatively, you can hit the Debug button to immediately start debugging the application. Changing the profile to another device will also change the simulator to appear like the other device selected. This can sometimes be undesirable, but often, it has little consequence.

Either way, you start the MDS simulator; when it starts up you will see a boring black box with lots and lots of text in it. This is because the MDS simulator is a console program and doesn't have a user interface that you can or should be interacting with. You can look at the output and sometimes see errors or trace network activity, but for the most part, whatever output is displayed is not very meaningful or useful.

There is one thing in particular that is both useful and important if you happen to see it. In and amongst the initial spew of output that happens when starting the MDS, you may find an error message indicating the port 8080 is in use.

Feb 21, 2010 3:45:50 PM org.apache.coyote.http11.Http11BaseProtocol init SEVERE: Error initializing endpoint Address already in use: JVM_Bind:8080
at org.apache.coyote.http11.Http11BaseProtocol.init(
at org.apache.catalina.connector.Connector.initialize(
at org.apache.catalina.startup.Embedded.start(
at net.rim.application.ipproxyservice.TomcatThread.startTomcat(Unknown Source)
at Source)


The MDS simulator must use port 8080 in order to operate. This port is used fairly commonly by other applications so chances are pretty good that another application might already be using that port. If this is the case, you must stop the other application and restart the MDS simulator. The MDS simulator won't abort if the port is already in use either, so unless you look for it, you might believe the MDS simulator is operating normally when it is not.

The port that the simulator uses is not something that you can just change through a configuration either. There is no configuration option available to change the port. The device simulator will be expecting to make a connection to port 8080 as well, and so these values are just hardcoded into both applications.

Once you are sure that the MDS simulator is running properly, you can pretty much forget about it. If you configured Eclipse to start the MDS simulator when debugging, then it will also terminate the MDS simulator when you are done debugging. If you started it manually, you will have to terminate it manually as well. This is done by closing the command prompt window or by pressing the Ctrl + C in the window.

If you started the MDS simulator manually you can leave it running through multiple debugging sessions. There is no real need to terminate it after each one. As the simulator runs, you will see regular activity in the output window, even if you aren't using it at that moment. However, when you make connections through the simulator by using the MDS transport you will see a lot of activity in the window as it works to process the request. What does it all mean? I don't really know, but it's there for the intrepid adventurer wanting to study it.

I think it's probably very common to have development environments for both the BlackBerry as well as whatever server-side software you plan to use on the same computer and to try to debug them both at the same time. Surprisingly, this may not be the best scenario, especially if you plan to use the MDS simulator.

Remember that the MDS Simulator is truly just a scaled down version of the MDS component, which is part of the BlackBerry Enterprise Server. Also remember that when using the MDS transport, the connection isn't made on the handheld itself. Instead, the MDS component makes the connection for you and then passes any data that came from the connection back to you.

Because of this, the MDS component and, by association, the MDS simulator specifically forbids connections to localhost or its numeric equivalent This would, in effect, open a connection back to the server that is running the MDS component instead of the handheld as one might expect. There isn't any good reason to do that, in fact it is considered a security risk so the MDS server just forbids any connections to that address.

As a result, if you want to debug your server on the same workstation that you have the MDS simulator running on you must use the external address of that computer. Most of the time, you don't know the address as it is given to your workstation dynamically by the router. You can find it by running the command-line application ipconfig.exe.

Using the external IP of your computer can introduce a new layer of routing issues though, which can make setting up a development environment very frustrating. Sometimes, the computer or the network just doesn't know how to route traffic back to the computer properly when the external address is used.

  •  BlackBerry Java Application Development : Networking - The transport-so many possibilities
  •  Huawei Ascend G300 On Vodafone
  •  Nokia's Extreme Megapixel Bid
  •  U-Mobile 21Mbps MiFi Modem - U And Mi
  •  Motorola ATRIX 2 - ATRIX: Part 2
  •  ASUS Eee Pad MeMO 171 - Got The MeMO?
  •  Samsung GALAXY Tab 7.7 - The 7.7-inch Wonder
  •  HTC One X - This Is The One
  •  Garmin Nuvi 50LM - nuviGating Our Way
  •  BlackBerry Java Application Development : Networking - parsing the response
  •  BlackBerry Java Application Development : Networking - calling a web service
  •  Ipad : Presentations with Keynote - Adding Transitions (part 2) - Object Transitions
  •  Ipad : Presentations with Keynote - Adding Transitions (part 1) - Magic Move
  •  What the world is waiting for ?
  •  Galaxy Tab 10.1 - Touchy-feely
  •  Le Pan II - Entry-level Honeycomb tablet
  •  Mobile - The Good, The Budget And The Surprising
  •  The Blackberry OS 2.0 - So, The Playbook Is Whole
  •  Mobile Phone Update Fever (Part 4)
  •  Mobile Phone Update Fever (Part 3)
    Top 10
    DirectX 10 Game Programming : 3D Introduction - Optimizing the Drawing Using Index Buffers
    DirectX 10 Game Programming : 3D Introduction - Drawing a Triangle
    Windows Server 2008 and Windows Vista : Architecture of Advanced Group Policy Management (part 2) - Server Installation
    Windows Server 2008 and Windows Vista : Architecture of Advanced Group Policy Management (part 1)
    .NET Debugging : Introduction to the Tools - Reflector for .NET, PowerDbg, Managed Debugging Assistants
    .NET Debugging : Introduction to the Tools - CLR Profiler, Performance Counters
    Nikon 1 J2 With Stylish Design And Dependable Image And Video Quality
    Canon Powershot D20 - Super-Durable Waterproof Camera
    Fujifilm Finepix F800EXR – Another Excellent EXR
    Sony NEX-6 – The Best Compact Camera
    Most View
    All We Need To Know About Green Computing (Part 3)
    Play It Smart (Part 4) - Sony 46HX750
    Screen Saver Dos and Don'ts in Vista
    Use Preview to Edit On Your Mac (Part 1)
    Adobe Illustrator CS5 : Proofing and Printing Documents - Finding and Replacing Text and Elements
    Microsoft Wedge Touch Mouse - Windows 8-Friendly Four-Way Scrolling Anywhere
    Sharepoint 2010 : BCS Architecture - Presentation & Core Components
    Adobe Flash Catalyst CS5 : Using the Drawing Tools (part 1) - Set strokes and fills
    Buffer Restrictions
    Create Your Own E-Books (Part 1)
    Troubleshooting Windows 7 Programs and Features
    AOC MyStage E2343Fi 23" LED Monitor
    Fight Icon Blight
    Server-Side Browser Detection and Content Delivery : Mobile Detection (part 3) - Transcoders
    Windows Phone 7 Development : Revising WeatherRx to Manage Slow Data Connections
    The Complete Guide To Garageband (Part 3)
    SQL Server 2008 : Using @@IDENTITY and NEWID Functions in DML Statements
    Algorithms for Compiler Design: LOOP OPTIMIZATION
    .NET Components : Configuring Permissions
    Windows Phone 7 Development : Working with Video (part 1)