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
New Developer
Posts: 6
Registered: ‎07-29-2008
My Device: Not Specified

Unable to connect to a server running on my localhost from the simulator via MDS simulator

Environment

Blackberry Simulator-> Blackberry 8300 smartphone(EDGE) v4.5.0.44 (JDE 4.5)

MDS Simulator-> Version contained with JDE 4.5

Issue: I am currently writing an application which needs to communicate with a JBoss server. I am running the server on my localhost at port 8080. I have modified the MDS to listen on 9080.

I am trying to execute the following code from the simulator which is attempting to communicate

with my servlet at the address specified:

 

HttpConnection httpConnection = (HttpConnection)Connector.open("http://192.168.1.100:8080/RemoteCellTestServer/controller");

httpConnection.setRequestMethod(HttpConnection.POST);httpConnection.setRequestProperty(

"Content-Type", "application/x-www-form-urlencoded");String params = "action=saveSMS&address=1234543&message=sheesh&id=3";

 

httpConnection.setRequestProperty("action", "saveSMS");httpConnection.setRequestProperty(

"address", "43234542");

httpConnection.setRequestProperty("message", ((TextMessage)outMsg).getPayloadText());httpConnection.setRequestProperty(

"id", "3");

httpConnection.openDataOutputStream().write(params.getBytes());

String response = httpConnection.getResponseMessage();

System.
out.println("RESP:ID" + httpConnection.getHeaderField("id"));

System.out.println("RESP:ADDR" + httpConnection.getHeaderField("address"));System.

out.println("RESP:MSG" + httpConnection.getHeaderField("message"));

System.out.println("RemoteCellSmiley FrustratedMSMonitor:notifyOutgoingMessage->responseFromServer:" + response);

I have results as follows:

If I use localhost or the loopback addr 127...... I recv a 403 error

If I use the address above from ipconfig on windows i get a 400 bad request. I have seen several threads with regards to this but everyone

else seems to be needing a proxy. I am not in a corporate env and don't

need a proxy. It simply appears that MDS will not allow me to connect

to the localhost which I need to do ASAP to develop the server side

for our application.

 

Your assistance is greatly appreciated.

 

TC

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

Re: Unable to connect to a server running on my localhost from the simulator via MDS simulator

The MDS Simulator does not allow connections to localhost or 127.0.0.1.  Instead, you should be able to use your actual IP address or machine name of your PC.

 

Do you have any local firewalls on your PC that could be blocking the connection?

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: 6
Registered: ‎07-29-2008
My Device: Not Specified

Re: Unable to connect to a server running on my localhost from the simulator via MDS simulator

Mark,

 

Thanks for the quick response. I have disabled the firewalls and I am still unable to connect to the address from ipconfig. I recv a bad request 400 and my server is not receiving the request. One thing to note when pinging my local host by name it returns an IPv6 address is this supported by the MDS environment? Is there anything I can do in the configuration of the MDS env to allow connection to the localhost or loopback?

 

Thanks again,

 

TC

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

Re: Unable to connect to a server running on my localhost from the simulator via MDS simulator

Does your PC also have an IPv4 address?  Your code sample above shows a URL with an IPv4 address.

 

Please enable verbose logging in the MDS Simulator by following the steps here:

 

How To - Enable HTTP and HTML logging in the Mobile Data Service Simulator
Article Number: DB-00156

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800738/800792/801079/...

 

Please also add the following 2 lines if they are not present.

 

Logging.file.location=logs Logging.file.log.level=4

 

Then post the log file found in C:\Program Files\Research In Motion\BlackBerry JDE 4.5.0\MDS\logs.  It should have a .txt extension and the current date.

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: 6
Registered: ‎07-29-2008
My Device: Not Specified

Re: Unable to connect to a server running on my localhost from the simulator via MDS simulator

Mark,

 

I have configured the environment as prescribed and have generated a log file. Is there a way to post the log file?

The limit is 20,000 characters per post thus the post of the log content is failing.

 

Please advise,

 

Trent Cooper

 

Note: I disabled IPv6 with no change in result.

New Developer
Posts: 6
Registered: ‎07-29-2008
My Device: Not Specified

Re: Unable to connect to a server running on my localhost from the simulator via MDS simulator

Mark,

 

Sorry for the inconvenience. After investigating the logs for both MDS and JBoss I have found that with the version of JBoss I am using (4.2.2) they are no longer binding to 0.0.0.0. I restarted the server with a param to bind to the IP of my host and it works fine. Once again I apologize for the inconvenience.

 

Trent Cooper

New Developer
Posts: 54
Registered: ‎10-07-2008
My Device: Not Specified

Re: Unable to connect to a server running on my localhost from the simulator via MDS simulator

Hi,

 

I´m experiencing the same problem.

 

I want to connect to my localhost, I got the ip and it resposes http error 403, forbiden

 

I can browse it from explorer, but not in the BB simulator.

 

If I connect from other computer to the server, It asks me for login and password, then I browse the services.

 

 

Some one knows how to solve it?

 

I´m getting frustrated with this! Smiley Mad

 

Thanks in advance!

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Unable to connect to a server running on my localhost from the simulator via MDS simulator

I have found that remapping the host name on my test system works best for me. This way, I don't have to worry about changing the URL back to the production value before I do a distribution build.

 

Edit the file windows/system32/etc/hosts and add an entry like this:

 

"127.0.0.1 www.foobar.com"  (substitute your host URL)

 

MDS will connect to this fine (in my experience). When you are finished testing just comment out the entry with a '#' character.

 

Of course, you have to make sure you are doing a "direct" connection when working on the simulator.

 

New Developer
Posts: 54
Registered: ‎10-07-2008
My Device: Not Specified

Re: Unable to connect to a server running on my localhost from the simulator via MDS simulator

Thanks Rex,

 

It worked, like you say, you don´t change the value before production

 

Regards

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

Re: Unable to connect to a server running on my localhost from the simulator via MDS simulator

The BlackBerry Simulator is not able to connect to "localhost" or 127.0.0.1.  However, if you use your actual PC name or IP address, you should be able to connect.
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