ChannelAuthorizer supports only synchronous flow
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 15/100
Línea de trabajo
The work centers on the ChannelAuthorizer interface and its authorize(channelName, socketId) method, which returns a String synchronously. Start by reading how the authorizer's result is consumed when a private or presence channel subscribes. The issue proposes a callback-based variant plus a compatibility path for existing implementers, but the API shape is not settled. Done would require an agreed design, a backward-compatible implementation, and tests for both sync and async authorizers.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What is the issue?
Currently ChannelAuthorizer expects a synchronous authorize implementation that returns a string.
It would be nice to rewrite it in a more asynchronous way, so that ChannelAuthorizer interface wouldn't force the implementation to block the thread if authorize requires async job.
It limits Kotlin usage e.g. in your React Native SDK, that needs async job by design (of React Native bridge):
Native Java/Kotlin module sends an event to Javascript and later Javascript calls Native module with auth object.
Related issue in your React Native SDK: https://github.com/pusher/pusher-websocket-react-native/issues/37
Is it a crash report? Submit stack traces or anything that you think would help
Nope, but please check the linked issues for more context and possible freezes/errors.
Any improvements you suggest
The React Native SDK (Android/Kotlin code) uses mutex to block the thread and wait until JavaScript returns proper auth object through RN bridge.
It's not really a common flow in RN world (to block the thread in RN module), because it can lead to various issues/freezes/crashes/leaks.
Instead, it is preferred to implement logic in an asynchronous way (listeners/storing callbacks) since RN bridge is also asynchronous.
There was a similar but more serious issue in iOS part of your React Native SDK:
https://github.com/pusher/pusher-websocket-react-native/issues/34
But it can be fixed by simply storing callbacks instead of blocking the thread:
https://github.com/pusher/pusher-websocket-react-native/pull/36
However, it is not possible to implement it like this in Android (Kotlin) part, because of the ChannelAuthorizer interface.
So my suggestion would be to rewrite ChannelAuthorizer in a way that supports async/delayed response.
For example (there might be a better way, but this should do the job):
// old
String authorize(String channelName, String socketId)
// new
void authorize(String channelName, String socketId, Callable<String> authResultCallback)
I know it would be a breaking change, but it should be possible to add backwards compatible util (that simply calls authResultCallback instead of return) or support both ways.
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 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 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 18/100
pusher/pusher-websocket-java#303 · 4 comentarios ·
Todos los issues de pusher/pusher-websocket-java
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
documentation good first issue priority: low
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
Gautam-aman/CODOVYN#52 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
ControlSystemStudio/phoebus#3998 ·
Los mantenedores suelen responder en 1 día
-
bug/错误
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
FCL-Team/FoldCraftLauncher#1982 · 2 comentarios ·
Los mantenedores suelen responder en 1 día