Comments (8)
@joedixon I found the issue everything was configured fine . I was upgrading my project from laravel 10 to 11 apparently this was the issue in the .env file. I was using BROADCAST_DRIVER in the .env file but the broadcasting.php file from 11 seems to use BROADCAST_CONNECTION I overlooked that. I should have updated the .env file to match the default option in broadcasting.php or vice versa
Now I can subscribe to private channel just fine and the auth you were asking about is now being passed correctly
from reverb.
Hey @KirinyetBrian from your screenshot, it doesn't look like an auth token is being sent when subscribing to the channel. Is one being returned correctly from the api/broadcasting/auth
endpoint?
from reverb.
Hey @KirinyetBrian from your screenshot, it doesn't look like an auth token is being sent when subscribing to the channel. Is one being returned correctly from the
api/broadcasting/auth
endpoint?
@joedixon No I was not sending an auth token simply because the user is not authenticated via token but through cookie based session authentication so i assumed I did not need to send a token. On a closer look on the browser the api/broadcasting/auth
doesnt return anything except an ok status 200. I am confused am I missing something? Must I explicitly send an auth token for authorization to happen even if I don't typically use sanctum token based auth : I followed what i in the docs about authenticating private channels and that was not mentioned kindly clarify https://laravel.com/docs/11.x/sanctum#authorizing-private-broadcast-channels
I also configured a global axios as required:
import Axios from 'axios'
const axios = Axios.create({
baseURL: process.env.NEXT_PUBLIC_BACKEND_URL,
headers: {
'X-Requested-With': 'XMLHttpRequest',
},
withCredentials: true,
withXSRFToken: true
})
export default axios
I event tried this which I don't believe should be the case but it didn't work still getting the same unauthorized error in reverb:
import Echo from "laravel-echo";
import axios from '@/lib/axios'
import Pusher from 'pusher-js';
const EchoConfig = () => {
window.Pusher = Pusher;
window.Echo = new Echo({
broadcaster: 'reverb',
key: process.env.NEXT_PUBLIC_REVERB_APP_KEY,
wsHost: window.location.hostname,
wsPort: process.env.NEXT_PUBLIC_REVERB_PORT,
wssPort: process.env.NEXT_PUBLIC_REVERB_PORT,
forceTLS: (process.env.NEXT_PUBLIC_REVERB_SCHEME ?? 'https') === 'https',
enabledTransports: ['ws', 'wss'],
auth:
{
headers:
{
Authorization: 'Bearer 21|mqK0lskDPZ0aDVo8uau4MPOn40SZrBrJp3RtbX461744d6b8',
}
},
authorizer: (channel, options) => {
return {
authorize: (socketId, callback) => {
axios.post('/api/broadcasting/auth', {
socket_id: socketId,
channel_name: channel.name
})
.then(response => {
console.log('success:' + response.data)
callback(false, response.data);
})
.catch(error => {
console.log('error:' + error)
callback(true, error);
});
}
};
},
})
}
export default EchoConfig;
from reverb.
How can I get the auth token?
from reverb.
This one also bit me! The Laravel Reverb docs should explicitly mention that either BROADCAST_DRIVER
or BROADCAST_CONNECTION
should be set to reverb
. I was able to get Reverb running fine locally (using Sail) without needing to change this envvar from pusher
, however, in my staging/VM environment, this needed to be set to reverb
.
from reverb.
Hello @KirinyetBrian Thanks to this issue I was able to solve my error.
Can you give me a hint on how you are using your EchoConfig function in your nextjs project? Where should I call?
from reverb.
@KirinyetBrian Thanks for the save! Clutch play for me. I've been looking for the fix all over.
from reverb.
How can I get the auth token?
I second this. We're trying to implement realtime connection with a Flutter app, and i'm not really sure where to get the auth token. I'm guessing it's the bearer token provided by sanctum but i'm not sure. Could you please elaborate? @KirinyetBrian
from reverb.
Related Issues (20)
- At calls WSS the server does not give response HOT 1
- "Data decoding error." on laravel + reverb websocket. Error message return after dispatch HOT 1
- set env variables for 'activity_timeout' HOT 2
- Method not allowed / Payload too large errors HOT 2
- WebSocket connection to Reverb server fails on HTTPS (wss) HOT 2
- Enhance library for extensibility HOT 1
- Compression HOT 1
- Reverb broadcasting of event is failing with pusher error. HOT 5
- Potential Issue with Pusher Ping/Pong Messages HOT 5
- Illuminate\Broadcasting\BroadcastException: Pusher error: cURL error 7: Failed to connect to localhost port 8080 after 0 ms: Couldn't connect to server (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) HOT 4
- Support For Laravel 10 HOT 1
- Cannot access dashboard HOT 5
- Details of members in presence channel HOT 1
- unable to handle event HOT 1
- Laravel Sail integration HOT 2
- Support for Laravel Reverb in Laravel Vapor HOT 1
- Laravel Reverb not connecting, everytime I make changes HOT 2
- Connection to redis fails if `REDIS_HOST` starts with `tls://` HOT 1
- Subscribe and Unsubscribe Event HOT 1
- Protocols\Pusher\Http\Controllers\PusherController receveived wrong argument HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reverb.