我作为客户端连接到私有(private) channel ,它通过身份验证过程(如文档“Authenticating users”中所写)转到我的应用程序 API,并使用此响应 - {"auth":"3h23kjh322kknkjsad:ea5dc004619ccg23s2e059f740h66684dd887fbexc8d8e56ae23b788 cdafa1b"}
,响应状态201
。
但是控制台日志显示下一步:
Pusher : State changed : connecting -> connected
Pusher : Couldn't get auth info from your webapp : 201
Pusher : Event sent : {"event":"pusher:ping","data":{}}
Pusher : Event recd : {"event":"pusher:pong","data":{}}
所以我不知道该怎么办,回复没问题
我的JS:
Pusher.log = function(message) {
if (window.console && window.console.log) {
window.console.log(message);
}
};
var pusher =
new Pusher('3h23kjh322kknkjsad', {
authEndpoint : 'http://localhost:3000/pusher/auth',
auth: {
headers : { 'Authorization':'bb692c03c2d8402ca3a5' }
}
});
var channel = pusher.subscribe('private-live_admin');
channel.bind('update', function(data) {
alert(data);
});
最佳答案
问题出在我的 API 返回的状态代码 201
上。 pusher-js lib只需要代码为 200
关于javascript - Pusher 订阅私有(private) channel - 无法获取身份验证信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36211730/