TooTallNate / Java-WebSocket

A barebones WebSocket client and server implementation written in 100% Java.
http://tootallnate.github.io/Java-WebSocket
MIT License
10.54k stars 2.58k forks source link

Canot connect to socket.io server #8

Closed demian85 closed 13 years ago

demian85 commented 14 years ago

Is there any onError method or a way to know if an error occured trying to connect?? I simply cannot connect and I don't know why... the onClose method is called, so?

TooTallNate commented 14 years ago

There's currently no onError method, though there should be. Perhaps you could prepare a patch :P

I'll get around sometime soon hopefully. In the meantime, I suggest placing some log statements throughout the handshake logic and recompiling, to maybe see where something is going wrong. Or using a wire sniffer (Wireshark) to get a view of what's going on that way. Sorry I can't be more help right now!

anismiles commented 13 years ago

I have adapted this project for Phonegap, and also implemented onError handler. Check here: https://github.com/anismiles/websocket-android-phonegap/ or https://github.com/anismiles/phonegap-android

-Animesh

TooTallNate commented 13 years ago

@anismiles It would be helpful if you forked and commited the changes as something merge-able

TooTallNate commented 13 years ago

Closing since I got confirmation from @dokipen that this lib does in fact connect successfully to Socket.IO servers, there just needs to be an additional layer on top of this lib that strips away the Socket.IO messaging protocol (i.e. parses JSON, reads heartbeats, session ID, etc.).

xpepermint commented 13 years ago

Socket.IO is still a problem. How did you fixed that? The WebSocketClient class connects to the server but then immediately close the connection.

java.lang.System.setProperty("java.net.preferIPv4Stack", "true"); java.lang.System.setProperty("java.net.preferIPv6Addresses", "false"); WSClient socket; try { socket = new WSClient(new URI("ws://192.168.1.100:8124")); socket.connect(); } catch (URISyntaxException e) { e.printStackTrace(); }

At the end I also get this message: SntpClient request time failed: java.net.SocketException: Address family not supported by protocol

anismiles commented 13 years ago

I used https://github.com/miksago/node-websocket-server instead of Socket.IO

-Animesh

xpepermint commented 13 years ago

Thanks man... i guess this is the way to go.