Gottox / socket.io-java-client

Socket.IO Client Implementation in Java
MIT License
950 stars 387 forks source link

Caused by: java.net.ConnectException: Connection refused: connect #104

Open VivekKulanthaisamy opened 10 years ago

VivekKulanthaisamy commented 10 years ago

socket = new SocketIO(); socket.connect("http://10.0.0.71:9092", this);// local ip address

// Sends a string to the server.
socket.send("Hello Server");

// Sends a JSON object to the server.
socket.send(new JSONObject().put("key", "value").put("key2",
        "another value"));

// Emits an event to the server.
socket.emit("event", "argument1", "argument2", 13.37);

} While using this code for creating server connection and by using socket.io.jar v1.0.

I get the following error io.socket.SocketIOException: Error while handshaking at io.socket.IOConnection.handshake(IOConnection.java:322) at io.socket.IOConnection.access$600(IOConnection.java:39) at io.socket.IOConnection$ConnectThread.run(IOConnection.java:199) Caused by: java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)

onuradsay commented 10 years ago

Try adding following line to your AndroidManifest.xml file. This should solve the connection error but if you are using socket.io 1.0.x this library won't work. I added @francoisTemasys's fork as a dependency and everything worked like a charm.

    <uses-permission android:name="android.permission.INTERNET" />