简体   繁体   中英

NodeJS + SocketIO android battery issue

I am using node.js socket.io library for building a android chat application with socket connection. but socket connection consume too much power that it drain battery by very high rate.

so is it possible to minimize power consumption by any mean of keeping socket idle or anything

below is my code where i have added in IOConnection.java class

public void transportMessage(String text) {
    // my logic
}

After lot of google and debuging i finally found solution and i hope it may help someone.

Actual Problem:

this problem is less concern to battery but more with Garbage collector which goes crazy after calling socket.disconnect() method. it cause your app to slow down and drain battery quickly.

Solution:

use java-websocket.jar version 1.3.0 instead of websocket.jar to resolve this.

More information:

see this issue and read comment of kikoso and lukas-hetzenecker

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM