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
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_18.104.22.168\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
java.net.BindException: Address already in use: JVM_Bind:8080
at net.rim.application.ipproxyservice.TomcatThread.startTomcat(Unknown Source)
at net.rim.application.ipproxyservice.TomcatThread.run(Unknown 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
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 127.0.0.1.
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
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.