ChannelAuthorizer supports only synchronous flow
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 15/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Java
- Star
- 315
- Fork
- 140
- Merge trung bình
- 11 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pusher/pusher-websocket-java
-
FileNotFoundException thrown when server responds with 400 or aboveCó thể đã có người làm @RaphaelFakhri đã nhận 8 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
pusher/pusher-websocket-java#261 ·
-
java.lang.NoClassDefFoundError: com.pusher.client.Pusher$$ExternalSyntheticLambda0 on Android API 21-22 anywayCó thể đã có người làm @Keith-wright đã nhận 9 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
pusher/pusher-websocket-java#366 ·
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 8/100
pusher/pusher-websocket-java#311 · 4 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 12/100
pusher/pusher-websocket-java#308 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
pusher/pusher-websocket-java#303 · 4 bình luận ·
Tất cả issue của pusher/pusher-websocket-java
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation good first issue priority: low
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
Gautam-aman/CODOVYN#52 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
ControlSystemStudio/phoebus#3998 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug/错误
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
FCL-Team/FoldCraftLauncher#1982 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày