ChannelAuthorizer supports only synchronous flow
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Java
- 星标
- 315
- 派生
- 140
- 平均合并
- 10 天 14 小时
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pusher/pusher-websocket-java 的其他 Issue
-
java.lang.NoClassDefFoundError: com.pusher.client.Pusher$$ExternalSyntheticLambda0 on Android API 21-22 anyway可能已有人在做 @Keith-wright 于 10 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 22/100
pusher/pusher-websocket-java#366 ·
-
难度 4/5 1-2 天 新手友好度 8/100
pusher/pusher-websocket-java#311 · 4 条评论 ·
-
难度 4/5 3-5 天 新手友好度 12/100
pusher/pusher-websocket-java#308 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 18/100
pusher/pusher-websocket-java#303 · 4 条评论 ·
-
bug
难度 3/5 1-2 天 新手友好度 35/100
pusher/pusher-websocket-java#299 · 2 条评论 · 2 个 reaction ·
查看 pusher/pusher-websocket-java 的全部 Issue
相似的 Issue
-
good first issue
难度 2/5 1-3 小时 新手友好度 90/100
authorjapps/zerocode#808 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
quarkusio/quarkus-agent-mcp#302 ·
维护者通常 2 天内回复
-
build
难度 1/5 1 小时以内 新手友好度 85/100
MetricsHub/metricshub-community#1472 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复