Skip to content
This repository has been archived by the owner on Mar 6, 2018. It is now read-only.

[ENH]Support for Socket 1.0.x #103

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

francoisTemasys
Copy link

This patch handle the main functions of socket.io in the 1.0.x version:
-connect
-send message
-send event
-disconnect

TODO list:
-Test ack
-binary event
-binary ack

@Trellmor
Copy link

Trellmor commented Jul 3, 2014

Great work. Is this backward compatible to older socket.io versions?

@onuradsay
Copy link

@francoisTemasys Currently, ant build fails because of an unused PolicyUtils import in IOMessage.java. Other than that the main functions work properly, thanks for the update.

@francoisTemasys
Copy link
Author

@Trellmor The update keeps the library backward compatible without any change on your side. The client is going to detect if the server is 0.9.x or 1.0x and react accordingly

@onuradsay I commited a fix. I just tested the ant build it works perfectly.

I figured a bug, if you use the function Thread.sleep() in one of the onMessage/onConnect, it also stop the socket.io library (and you don't receive anything anymore).

@goulwenlorcy
Copy link

Thanks for your work. Is there a way to use rooms implementation (join & leave)?

Edit: My mistakes, join & leave are server side, not client side.

@vigbk
Copy link

vigbk commented Jul 11, 2014

I am getting a null pointer exception when receiving an ack from the server. I m using socket.io version 0.9.14 on the server. This is the stack trace
java.lang.NullPointerException
at io.socket.IOConnection.transportMessage(IOConnection.java:826)
at io.socket.IOConnection.transportData(IOConnection.java:690)
at io.socket.XhrTransport$PollThread.run(XhrTransport.java:115)

@francoisTemasys
Copy link
Author

@vigbk Can you test this last fix?

@vigbk
Copy link

vigbk commented Jul 16, 2014

This crashes on the event connect itself. The connect event doesn't have field_data. Im guessing that is the reason it is crashing.

FATAL EXCEPTION: xhr-polling
java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
at io.socket.IOMessage.(IOMessage.java:239)
at io.socket.IOMessage.parseMessage(IOMessage.java:168)
at io.socket.IOConnection.transportMessage(IOConnection.java:721)
at io.socket.IOConnection.transportData(IOConnection.java:690)
at io.socket.XhrTransport$PollThread.run(XhrTransport.java:115)

@mjie
Copy link

mjie commented Jul 24, 2014

@francoisTemasys thanks for the code, I tried to contact Gottox about this amazing update, but no response yet..
I m new to Java and Android, hope anyone could help to answer 2 simple questions:

  1. I want to create a simple pushing app, does it mean I need to add the Socket into a Thread from background service?
  2. I did so, and test if it can reconnect when connection is temp disconnected, seems no something like heartbeat information shown in Logcat during the disconnection period. Anything special I need to do for reconnect, or doesn't it try to reconnect automatically as I used .js client api of Socket.IO?

Thank you,
Jerry

@francoisTemasys
Copy link
Author

@mjie I'm sorry but I don't think your questions have any link with upgrading to socket.io 1.0.x.

In your case, use Gottox java client with a socket.io server 0.9.x version that would be more stable for the java client. I'm sure you can find plenty of documentation for what you are looking for if it's just 2 simples problems.

@mjie
Copy link

mjie commented Jul 25, 2014

@francoisTemasys Thanks for your guide! Since socket.io 0.9.x is better for Android, I finally chose this https://github.com/koush/AndroidAsync to test, as it has more 'Star', so far so good. For those who is new to Android and Java as me, you can start with this example: https://github.com/Thanhktm/socketio_android which is easy to use. Hope it would be helpful.

@ghost
Copy link

ghost commented Jul 30, 2014

im getting the following error:

ERROR 13:59:34,482 [ConnectThread] PID- M- TID- AlertMonitor -Error occured
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.io.IOException: Server returned HTTP response code: 400 for

@francoisTemasys
Copy link
Author

@anthonythomasdesign I believe you are using the Gottox version and not my fork as there is nothing on line 322 in IOConnection.java for my fork.

@Trellmor
Copy link

Trellmor commented Aug 5, 2014

@francoisTemasys it looks like IOCallback.onConnect doesn't get called for connections to 0.9 servers.

@N1Knight
Copy link

Hi,
I am experiencing some problems using socket.io-client.java with netty-socketio server.

I am connecting to the server using the following code:

                        ip = "192.168.93.32";
            port= 8230;

            socketIo = new SocketIO();
            socketIo.connect("http://"+ip+":"+port+"/", new IOCallback() { 

                @Override
                public void onError(SocketIOException arg0) {                       
                    System.out.println("ERROR");
                }

                @Override
                public void onDisconnect() {                        
                    System.out.println("Disconnect");
                }

                @Override
                public void onConnect() {
                    System.out.println("Connect");          
                }
            });

I make a connection but the "onConnect" event is never called but in server side i can see new connection.
why is "onConnect" not invoked?
Do you have any idea why this is not working?

Thanks,

…11ce3e6758843b6' Dated:August 10, 2014 to support SSL
@raphschmidt
Copy link

@Trellmor Take a look at my fork for a fix for the onConnect handler not firing when connecting to 0.9.x servers.

@ZhouningMan
Copy link

ant build fails for me. Any idea? Thanks
image

@sanakanchha
Copy link

@francoisTemasys thanks for the upgrade.However, I get the same #100 FileNotFoundException as soon as I upgrade my socketIO server above 0.9.16.( I tried on 1.0 as well.)
Maybe I am missing something but how would this work for 1.0.x?

@ChandanShankar
Copy link

Hi, I'm new to android, I'm getting the the following error,

06-04 12:13:33.040: W/System.err(17338): SocketIOException: Error while handshaking
at .IOConnection.handshake(IOConnection.java:327)
at .IOConnection.access$7(IOConnection.java:290)
at .IOConnection$ConnectThread.run(IOConnection.java:198)
Caused by: java.lang.NullPointerException
at .IOConnection.handshake(IOConnection.java:307)
... 2 more,

As suggested i'm using socketIO server version 0.9.16, and folk of /Grantoo/socket.io-java-client

The same code is working for http domain, but its not working for https and SSL protocols.

Please help solving this.

@ZhouningMan
Copy link

I had the same problem, but I solved the problem by forking from this version https://github.com/robertoandrade/socket.io-java-client.git.

@ChandanShankar
Copy link

@ZhouningMan Thanks for the help its working fine now....!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.