Giter VIP home page Giter VIP logo

Comments (5)

dbzhang avatar dbzhang commented on July 30, 2024

Additionally, I intermittently run into the following fatal exception when I force a disconnect and quickly connect the socket again. I've tried catching these two exceptions in my function containing .connect(new IOCallback{...}); without any luck. Once again, am I doing something wrong here?

05-21 16:38:06.305: W/dalvikvm(7566): threadid=33: thread exiting with uncaught exception (group=0x4001e560)
05-21 16:38:06.305: E/AndroidRuntime(7566): FATAL EXCEPTION: backgroundTimer
05-21 16:38:06.305: E/AndroidRuntime(7566): java.lang.NullPointerException
05-21 16:38:06.305: E/AndroidRuntime(7566): at io.socket.IOConnection.connectTransport(IOConnection.java:323)
05-21 16:38:06.305: E/AndroidRuntime(7566): at io.socket.IOConnection.access$300(IOConnection.java:38)
05-21 16:38:06.305: E/AndroidRuntime(7566): at io.socket.IOConnection$ReconnectTask.run(IOConnection.java:173)
05-21 16:38:06.305: E/AndroidRuntime(7566): at java.util.Timer$TimerImpl.run(Timer.java:284)

from socket.io-java-client.

Gottox avatar Gottox commented on July 30, 2024

Can you attach the corresponding output of the server?

About your second post: This could be a bug. Did you create a new instance of SocketIO or reused the old one?
I forgot to document that SocketIO (as well as IOConnections, but they're only used internally) are invalidated once onError() or onDisconnect() is called. Use a fresh instance of SocketIO instead. In any way, the library shouldn't throw an NullpointerException but a RuntimeException when you try to reconnect with an invalidated IOConnection.

from socket.io-java-client.

dbzhang avatar dbzhang commented on July 30, 2024

Thanks for your quick response. Could you elaborate on what kind of server output you'd like?

As for the second post, my app has two states: one which requires a connection to the node server and one which does not. I force hard connects and disconnects to accomplish this, please let me know if there is a better approach.

When the connection is required:
I create a new instance of SocketIO and call .connect() with all my callback implementations each time the client connects. Sample code:
socket = new SocketIO(socketUrl);
socket.connect(new IOCallback() { ..my implementation.. });

When the connection is unnecessary:
I force a disconnect. SampleCode:
socket.disconnect();
socket = null;

from socket.io-java-client.

Gottox avatar Gottox commented on July 30, 2024

socket.io prints per default some status informations to stderr, they could be usefull.

It's ok to disconnect and reconnect to a server, but disconnecting/reconnecting should be done in the same thread, otherwise the state may be inconsistent.

What causes the reconnect error is the mutliton pattern in socket.io-java-client. When a SocketIO client connects to the server, it first looks up if there already is a established IOConnection to the server. If so, it is reused. In that way socket.io needs only one tcp-socket for any example.com/* address. My suspiction is, that the new SocketIO instance finds an IOConnection, which state is currently disconnecting.

May you recheck your issues with current master branch? - Please report if the behavior has changed. especially for your second issue.

from socket.io-java-client.

dbzhang avatar dbzhang commented on July 30, 2024

Just saw your new changes. I'll update my library and keep you posted on the status for the 2nd issue. Thanks a lot

from socket.io-java-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.