Comments (5)
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.
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.
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.
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.
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)
- Problem with Garbage collector HOT 1
- Reconnect mechanism HOT 1
- No ACK timeout / Possible memory leak?
- Device heat up HOT 1
- Why you using separate thread for user socket.io in example Chat.java? HOT 2
- How to fix this : io.socket.SocketIOException: 1+0 HOT 2
- Maven?
- Can't get emit respond HOT 1
- my android device doesn't reconnect itself after server restart
- Android Lollipop Support
- Can't disable heartbeat
- server.js
- Chat program handshake exception HOT 4
- Socket instantiation problem (Even i added socketio.jar ) HOT 2
- Issue in running the project HOT 2
- Configure path to the resource
- Windows 10 not working
- problem with https
- socket.io FileNotFoundException HOT 4
- Null pointer exception when emmiting to socket
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from socket.io-java-client.