Wrong presence channel behavior (Android/IOS)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Área
- mobile-dev
Línea de trabajo
The problem is in PresenceChannelImpl, in handleSubscriptionSuccessfulMessage, where idToUserMap is filled with put() calls but never cleared before the new user list is applied. Start by reading how idToUserMap is maintained across unsubscribe and resubscribe in PresenceChannelImpl. Done means that after a reconnect, getUsers() reflects only the users in the subscription_succeeded payload, and that a test covers a member leaving while the client was disconnected.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What is the issue?
Hello there! I found some incorrect behavior of presence channels after restore connection to channel.
Problem step-by-step:
- Connect to presence channel two or more users
- Go to in background - pusher disconnected
- Other users quit from channel
- Go to in foreground - pusher connected - we resubscribe to channel
- On onUsersInformationReceived we got old data of users in channel
Notate: Swift SDK has workaround with subscribing on "pusher:subscription_succeeded" and process this event separate from flow logic. In Java SDK we don't have such trick...
In PresenceChannelImpl when channel successfully subscribed we got event SUBSCRIPTION_SUCCESS_EVENT = "pusher_internal:subscription_succeeded" with processing in internal channel body and after that call onUsersInformationReceived for self interface.
Problem in idToUserMap map witch need to clear in this case, because if i'm not wrong with SUBSCRIPTION_SUCCESS_EVENT we getting actual data about users in presence channel but in current realisation we lost users who quit from channel while i was unsubscibed.
Debug of this point shown that problem exist - channel got json with 1 user but idToUserMap not cleared and return wrong users data
...
Is it a crash report? Submit stack traces or anything that you think would help
#class PresenceChannelImpl
@SuppressWarnings({ "rawtypes", "unchecked" })
private void handleSubscriptionSuccessfulMessage(final String message) {
final ChannelEventListener listener = getEventListener();
// extract data from the JSON message
final PresenceData presenceData = extractPresenceDataFrom(message);
if (presenceData == null) {
if (listener != null) {
listener.onError(
"Subscription failed: Presence data not found",
null
);
}
return;
}
final List<String> ids = presenceData.ids;
final Map<String, Object> hash = presenceData.hash;
if (ids != null && !ids.isEmpty()) {
// build the collection of Users
for (final String id : ids) {
final String userData = hash.get(id) != null ? GSON.toJson(hash.get(id)) : null;
final User user = new User(id, userData);
idToUserMap.put(id, user); <--- Problem - is not empty. Suggestion: need clear before process users data
}
}
if (listener != null) {
final PresenceChannelEventListener presenceListener = (PresenceChannelEventListener)listener;
presenceListener.onUsersInformationReceived(getName(), getUsers());
}
}
...
Any improvements you suggest
In this case clear idToUserMap before process users data. I may be wrong, then tell me the correct scenario for working with this type of channels
...
CC @pusher/mobile
- Lenguaje dominante
- Java
- Estrellas
- 315
- Forks
- 140
- Merge medio
- 11 d 5 h
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de pusher/pusher-websocket-java
-
FileNotFoundException thrown when server responds with 400 or abovePosiblemente ocupada @RaphaelFakhri la tomó hace 8 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
pusher/pusher-websocket-java#261 ·
-
java.lang.NoClassDefFoundError: com.pusher.client.Pusher$$ExternalSyntheticLambda0 on Android API 21-22 anywayPosiblemente ocupada @Keith-wright la tomó hace 9 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
pusher/pusher-websocket-java#366 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
pusher/pusher-websocket-java#340 · 3 comentarios · 7 reacciones ·
-
Dificultad 4/5 1-2 días Aptitud para principiantes 8/100
pusher/pusher-websocket-java#311 · 4 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 12/100
pusher/pusher-websocket-java#308 · 2 comentarios ·
Todos los issues de pusher/pusher-websocket-java
Issues similares
-
breaking change bug needs human review not ready priority medium size S
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
martin-francois/symphony-trello#1193 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Mend: dependency security vulnerability
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
status: waiting-for-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
spring-projects/spring-framework#37614 ·
Los mantenedores suelen responder en 1 día