我有一个问题的框架Laravel包。我想在我的项目上聊天,让人们互相交谈。
问题是,当我尝试在pusher上访问我的应用程序时,我收到以下两个错误代码:
WebSocket connection to 'ws://ws.pusherapp.com/app/my_app_key?protocol=7&client=js&version=2.2.4&flash=false' failed: WebSocket is closed before the connection is established.
pusher.js:12 Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":4001,"message":"Could not find app by key my_app_key. Perhaps you're connecting to the wrong cluster."}}}
这个包裹叫Confer(https://github.com/dazzz1er/confer).
我所有的文件都是正确的,但它不起作用!我在Laravel 5.1
在配置/services.php
'pusher' => [
'public' => 'my_app_key',
'secret' => 'my_secret_key',
'app_id' => 'my_app_id'
]
我的刀片模板
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> My project - @yield('title') </title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="./css/style.css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" type="text/css" href="../css/sweetalert.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link href="/vendor/confer/css/confer.css" rel="stylesheet">
<script src="./js/jquery-1.12.0.min.js" charset="utf-8"></script>
<script src="./js/bootstrap.min.js" charset="utf-8"></script>
<script src="./js/jcarousel.js"></script>
<script src="./js/jcarousel-basic.js" charset="utf-8"></script>
<script src="../../js/sweetalert.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body class="homepage">
@include('confer::confer')
@include('sweet::alert')
@include('layouts.includes.nav')
@include('layouts.includes.header')
@yield('content')
@include('layouts.includes.footer')
<script src="./js/pusher.js"></script>
<script src="./js/moment.js"></script>
@include('confer::js')
</body>
</html>
谢谢你的帮助!:)
编辑:我收到回复,这是版本之间的差异!有人可以给我帮助转换在Laravel 5 Confer到Laravel 5.1?谢谢你!:)
这里是完整的演示拉威尔5!https://github.com/dazzz1er/confer-demo
如果你不是美国人,我想你需要把集群改成“欧盟”https://pusher.com/docs/clusters#/lang=php
此处的错误消息无法按键查找应用程序my_app_key
表明您尚未使用实际的推送器凭据替换这些凭据,您可以在推送器仪表板上找到这些凭据。
推送程序库在未提供有效凭据时引发该错误。如果您已经更新了config/services。php
正确地说,您可能需要重新启动服务器才能使更改生效。
您需要更改配置/服务。php
使用可以在“应用程序键”部分下的推送器仪表板中找到的键。例如:
我不会假装抄袭别人的答案,但我只是想分享对我有用的东西。在env文件中,我没有正确配置BROADCAST_DRIVER=推送器。然后,我检查群集是否与我在他们的网站上创建推送应用程序时给我的群集相同。您还可以在“应用密钥”选项卡下找到分配给您的群集名称。然后我重启Chrome网络浏览器,最后我通过运行代客重启来重启服务器。根据您的开发环境,您可以使用不同的命令重新启动服务器。