Closed zorenkonte closed 3 months ago
Hi @zorenkonte I am not sure if you have set up auth. for ably properly. I would recommend you to go through following docs carefully
requestTokenFn
is mostly not required when auth is implemented internally. You just need to specify authEndpoint
as a part of clientOptions
. You should check https://github.com/ably-forks/laravel-echo?tab=readme-ov-file#installation. Also make sure you are using ably
version <=1.x
as specified in the install command.
If issue still persists, you can create code with dummy repo. where issue can be reproduced and we can check where things are going wrong
Hi @sacOO7,
Thank you for your reply. I apologize for the delayed response. I stopped working on this issue after a few attempts and moved on to another task. However, I recently revisited it and believe I have identified the cause of the 401 error.
I am using jwt-auth for authentication, which by default checks the token payload in the request. Ably Laravel Broadcaster also returns and find a token
with each authentication request. As a result, jwt-auth interprets this as the token authentication code, which causes a 401 error on subsequent requests because Ably Laravel Broadcaster's token payload conflicts with jwt-auth
Commenting out the InputSource resolved the issue for me or by following the instruction from this reply.
However, this solution could be improved. It would be beneficial to provide an option for a custom token key name in the payload to avoid conflicts with other authentication methods.
Hi @zorenkonte thanks for the response! I have created a separate issue for the same -> https://github.com/ably-forks/laravel-echo/issues/37 👍
Thank you, @sacOO7 Closing this issue now.
Echo Version
1.0.4
Laravel Version
8.83.27
PHP Version
8.3.6
NPM Version
10.5.2
Database Driver & Version
No response
Description
I'm encountering a 401 (unauthorized) error when attempting to subscribe to private channels using Laravel Echo and Ably integration. This issue arose after switching from Pusher to Ably because im having an issue about presence channel (where someone also experienced similar problems - https://stackoverflow.com/questions/57297057/laravel-echo-server-detect-user-disconnection). The first call to a public channel works successfully, but subsequent calls to private channels fail. Reordering the calls doesn't resolve the issue. I dont have problems with authentication before I switch to ably as broadcaster.
Expected Behavior:
All channel subscriptions (public and private) should be successful using the provided authentication mechanism.
Actual Behavior:
window.Echo.join(channels.online)
(public channel) subscribes successfully.window.Echo.private(...)
(private channels) result in a 401 error.Here is my full setup
Steps To Reproduce
Steps to Reproduce:
window.Echo.private('user.2')
).Expected Result:
All channel subscriptions should succeed.
Actual Result:
Only the first channel subscription succeeds. Subsequent channel subscriptions result in a 401 error.
Additional Information:
requestTokenFn
function to retrieve a fresh token, but the issue persists. (#26 )I would appreciate any guidance on how to resolve this issue and successfully subscribe to private channels using this package.