Skip to content

Commit f32956f

Browse files
author
Zan Markan
committed
Log error for if onClose happens in reconnecting state and moved resetting the number of reconnection attempts after the state has been updated to Connected
1 parent a0e0870 commit f32956f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/com/pusher/client/connection/websocket/WebSocketConnection.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ private void handleEvent(final String event, final String wholeMessage) {
178178
private void handleInternalEvent(final String event, final String wholeMessage) {
179179
if (event.equals("pusher:connection_established")) {
180180
handleConnectionMessage(wholeMessage);
181-
reconnectAttempts = 0;
182181
}
183182
else if (event.equals("pusher:error")) {
184183
handleError(wholeMessage);
@@ -193,6 +192,7 @@ private void handleConnectionMessage(final String message) {
193192
socketId = (String)dataMap.get("socket_id");
194193

195194
updateState(ConnectionState.CONNECTED);
195+
reconnectAttempts = 0;
196196
}
197197

198198
@SuppressWarnings("rawtypes")
@@ -259,8 +259,8 @@ public void run() {
259259

260260
@Override
261261
public void onClose(final int code, final String reason, final boolean remote) {
262-
if (state == ConnectionState.DISCONNECTED) {
263-
log.error("Received close from underlying socket when already disconnected. " + "Close code ["
262+
if (state == ConnectionState.DISCONNECTED || state == ConnectionState.RECONNECTING) {
263+
log.error("Received close from underlying socket when already disconnected." + "Close code ["
264264
+ code + "], Reason [" + reason + "], Remote [" + remote + "]");
265265
return;
266266
}

0 commit comments

Comments
 (0)