views:

191

answers:

2

I'm guessing this will be such a newbee question but I hit a wall and...

I am running the jWebSocket (http://jwebsocket.org) stand-alone server. For a client I am using Weberknecht (http://code.google.com/p/weberknecht/) And Eclipse is my IDE of choice.

Now, when I start the server and run the Weberknecht client like a normal Java application I get a connection. Granted, the connection is quickly dropped because the handshake needs to be configured but at least the server shows me a connection was attempted.

However, when I use the exact same code in my hello world Android app I get nothing :( I am also not seeing any console outputs even thought I used both Log.i and Log.v

Log.i(TAG, "YEI! connectToWS 1!");
Log.v(TAG, "YEI! connectToWS 1!");

Maybe I am calling the connect method in the wrong place?

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    connectToWS();
...

Any help would be GREATLY appreciated!

A: 

A bit more information would probably help. What are the contents of your connectToWS() method? Finding a connection issue is difficult without the code that does the connection.

Brad Gardner
I wanted to avoid pasting that code which is why I gave the link to it: http://code.google.com/p/weberknecht/The entire content of that function is the first thing that is shown on his page.But, I already got a hint that maybe the problem is in trying to connect to LOCALHOST from the Android emulator. If my knowledge is adequate, the emulator is a VM and thus will look for the server on itself... But I would still expect and error in the Eclipse console OR at least my Log.v calls to work :(
DrCoPe
A: 

The problem was the localhost access. Once I changed it to 10.0.2.2 it worked.

DrCoPe