laravel中的Broadcast / Auth 500 Pusher

时间:2018-07-24 06:54:34

标签: laravel pusher

在我的应用中,我使用推送器发送打字员通知,但出现此错误:

Couldn't get auth info from your webapp : 500

放在页脚中的推送程序的javascript代码:

<script src="https://js.pusher.com/4.1/pusher.min.js"></script>
<script>
  Pusher.logToConsole = true;

  var pusher = new Pusher('xxxxxxxxxxxxxxxxx', {
      cluster: 'ap2',
      encrypted: true,
  authEndpoint: "/broadcasting/auth",
  auth: {
      params: {
          'X-CSRF-Token': $('meta[name="csrf-token"]')
            .attr('content')
      }
  }
  });

  var channel = pusher.subscribe(
    'private-App.Typist.' + {{$typistId}}
  );

  channel.bind('NewTypeOrder', function(data) {
      alert('hi');
  });

在channels.php中

Broadcast::channel('App.Typist.{id}', function (Typist $typist, $id) {
    return true;
});

以及在Events / EventTypeOrder.php

class NewTypeOrder implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;

public $typist;
/**
 * Create a new event instance.
 *
 * @return void
 */
public function __construct(Typist $typist)
{
    $this->typist = $typist;
}

/**
 * Get the channels the event should broadcast on.
 *
 * @return Channel|array
 */
public function broadcastOn()
{
    return new PrivateChannel('App.Typist.' . $this->typist->id);
}
}

我的打字员表完全来自用户表,没有使用打字员的laravel身份验证,因为laravel身份验证仅用于用户。

在laravel.log中

[2018-07-22 20:27:38] local.ERROR: ErrorException: Key file 
"file://C:\xampp\htdocs\samane_typax_5.4\storage\oauth-public.key" 
permissions are not correct, should be 600 or 660 instead of 666 in 
C:\xampp\htdocs\samane_typax_5.4\vendor\league\oauth2- 
server\src\CryptKey.php:57
Stack trace:

现在我该怎么办?

1 个答案:

答案 0 :(得分:0)

在命令行上,输入:php artisan tinker

然后粘贴以下内容:

chmod(storage_path('oauth-public.key'), 0660)

这应该设置正确的文件权限,一旦按回车键,错误应该消失/更改:)