Close HTTP connection if websocket request fails
When the websocket "switch over" request fails, close the response to avoid resource leaks in OkHttp
This commit is contained in:
parent
41a3031f37
commit
40f0411bf3
|
@ -158,6 +158,7 @@ public class MyFreeCamsClient {
|
||||||
super.onFailure(webSocket, t, response);
|
super.onFailure(webSocket, t, response);
|
||||||
int code = response.code();
|
int code = response.code();
|
||||||
String message = response.message();
|
String message = response.message();
|
||||||
|
response.close();
|
||||||
MyFreeCamsClient.this.ws = null;
|
MyFreeCamsClient.this.ws = null;
|
||||||
LOG.error("MFC websocket failure: {} {}", code, message, t);
|
LOG.error("MFC websocket failure: {} {}", code, message, t);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue