ChannelAuthorizer supports only synchronous flow
まだ誰も着手していません。
評価
調査の方向性
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
- 平均マージ
- 11日 5時間
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pusher/pusher-websocket-java のほかの issue
-
FileNotFoundException thrown when server responds with 400 or above対応中かも @RaphaelFakhri が 8 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
pusher/pusher-websocket-java#261 ·
-
java.lang.NoClassDefFoundError: com.pusher.client.Pusher$$ExternalSyntheticLambda0 on Android API 21-22 anyway対応中かも @Keith-wright が 8 日前に担当しました。 オープン
難易度 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 件 ·
pusher/pusher-websocket-java の issue をすべて見る
似ている issue
-
[BUG] micronaut-serde-oracle-jdbc-json brings a second OJDBC driver onto the runtime classpath対応中かも @ZARAYACH が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
micronaut-projects/micronaut-serialization#1494 · コメント 4 件 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 2 日以内に返信
-
code-health feature/sync OS/Android QA/Test-Plan-Specified QA/Yes
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
brave/brave-browser#60327 ·
メンテナーはふだん 1 日以内に返信
-
Type: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
it-at-m/raumreservierung#383 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
aws/context-ontology-accelerator#325 ·
メンテナーはふだん 1 日以内に返信