• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps WebSocketClient socket closes after the android device is kept idle for some time

I am working on an android application which has a client-server architecture. I am creating a WebSocketClient to connect to a server. Every thing works fine till I keep the device idle for sometime. When the device is kept idle for sometime, I connection with the server closes for some reason. I am not using java_websocket.jar for this.

Refer to the following code :

WebSocketClient client =newWebSocketClient(new URI(path), draft){

@Overridepublicvoid onMessage(String message){
// some code here
}

@Overridepublicvoid onOpen(ServerHandshake handshake){
// Some code here
}

@Overridepublicvoid onError(Exception ex){
// Some code here
}};
client.connect();

I would appreciate if someone would help me as I am not able to resolve this issue since many days.
 
Last edited:
Back
Top Bottom