NodeJS + SocketIO android battery issue

2019-04-13 17:01发布

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
}

1条回答
劳资没心,怎么记你
2楼-- · 2019-04-13 17:35

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

查看更多
登录 后发表回答