标签: laravel-websockets

无法找到可发布的资源

我曾尝试使用发布此包

php artisan vendor:publish --provider="BeyondCode\LaravelWebSockets\WebSocketsServiceProvider" --tag="migrations"
Run Code Online (Sandbox Code Playgroud)

但我得到

Unable to locate publishable resources

publishing complete
Run Code Online (Sandbox Code Playgroud)

我不知道问题的原因是什么。任何可以帮助我的人。

安装输出

Installing beyondcode/laravel-websockets (1.4.0): Downloading (100%)
symfony/polyfill-intl-idn suggests installing ext-intl (For best performance)
symfony/psr-http-message-bridge suggests installing nyholm/psr7 (For a super lightweight PSR-7/17 implementation)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
symfony/event-dispatcher suggests installing symfony/dependency-injection
symfony/var-dumper suggests installing ext-intl (To show region name in time zone dump)
symfony/http-kernel suggests installing symfony/browser-kit
symfony/http-kernel suggests installing symfony/config
symfony/http-kernel …
Run Code Online (Sandbox Code Playgroud)

laravel laravel-websockets

19
推荐指数
5
解决办法
2万
查看次数

Laravel Echo 不听

我设置了一个事件和新频道:

class TaskCreated implements shouldBroadcast
 {
use Dispatchable, InteractsWithSockets, SerializesModels;
public $task;

public function __construct(Task $task)
{
    $this->task = $task;
}

}
Run Code Online (Sandbox Code Playgroud)

并安装 Echo 并进行设置

 import Echo from "laravel-echo"
window.Pusher = require('pusher-js');
window.Echo = new Echo({
    broadcaster: 'pusher',
    key: 'pusher-key',
    cluster: 'ap2',
    encrypted: true
});
Run Code Online (Sandbox Code Playgroud)

然后我在发布任务时调用 TaskCreated 事件

event(new TaskCreated($task));
Run Code Online (Sandbox Code Playgroud)

然而,问题是 Echo 不听推送日志或任何东西。即使在 laravel-websockets 中,事件是作为 api 消息创建的。

这是 vue js Echo 实现:

 mounted () {
        axios.get('/tasks').then(response => (this.tasks = response.data));

       Echo.channel('taskCreated').listen('TaskCreated', (e) => {
            console.log(e);
            this.tasks.push(task.body)
        });
Run Code Online (Sandbox Code Playgroud)

在仪表板中:

api-message Channel: …

php laravel vue.js laravel-websockets laravel-7

7
推荐指数
2
解决办法
7790
查看次数

如何使用 Laravel WebSockets 在 Laravel 中通过 WebSocket 将消息从客户端发送回服务器?

WebSocket 允许双向通信:服务器可以向浏览器发送消息,浏览器 - 客户端 - 可以通过相同的连接进行响应。

我正在 Laravel 6 中使用以下方法实现聊天应用程序:

我已经知道服务器触发事件​​并且客户端侦听这些事件如下。

  1. 安装 Laravel WebSockets 包。

composer require beyondcode/laravel-websockets

  1. 配置config/broadcasting.php.
        'pusher' => [
            'driver' => 'pusher',
            'key' => xxx,
            'secret' => xxx,
            'app_id' => xxx,
            'options' => [
                'cluster' => xxx,
                'encrypted' => true,
                'useTLS' => true, 
                'host' => '127.0.0.1',
                'port' => 6001,
                'scheme' => 'https',
            ],
        ],
    ]
Run Code Online (Sandbox Code Playgroud)
  1. 配置 config/websockets.php
'apps' => [
        [
            'id' => xxx,
            'name' …
Run Code Online (Sandbox Code Playgroud)

javascript php websocket laravel laravel-websockets

6
推荐指数
1
解决办法
5030
查看次数

Laravel Echo 尝试连接 wss 而不是 ws

我正在使用 Pusher Laravel Webaockets 包的替换。

\n\n

在我的应用程序中 Laravel Echo 尝试连接 v\xc3\xada wss 而不是 ws,因此失败。

\n\n

我的资源/js/bootstrap.js:

\n\n
import Echo from \'laravel-echo\'\nwindow.Pusher = require(\'pusher-js\');\n\nwindow.Echo = new Echo({\n    broadcaster: \'pusher\',\n    key: process.env.MIX_PUSHER_APP_KEY,\n    cluster: process.env.MIX_PUSHER_APP_CLUSTER,\n    wsHost: window.location.hostname,\n    wsPort: 6001,\n    disableStats: true,\n    encrypted: false,\n    enabledTransports: [\'ws\'],\n});\n
Run Code Online (Sandbox Code Playgroud)\n\n

config/broadcasting.php 中的广播连接:

\n\n
\'pusher\' => [\n            \'driver\' => \'pusher\',\n            \'key\' => env(\'PUSHER_APP_KEY\'),\n            \'secret\' => env(\'PUSHER_APP_SECRET\'),\n            \'app_id\' => env(\'PUSHER_APP_ID\'),\n            \'options\' => [\n                \'cluster\' => env(\'PUSHER_APP_CLUSTER\'),\n                \'encrypted\' => false,\n                \'host\' => \'127.0.0.1\',\n                \'port\' => 6001,\n                \'scheme\' => \'http\',\n            ],\n …
Run Code Online (Sandbox Code Playgroud)

laravel-echo laravel-websockets

6
推荐指数
1
解决办法
4066
查看次数

Beyondcode laravel-websocket 未连接到服务器

我正在尝试构建一个聊天应用程序,并使用Beyondcode/laravel-websockets来实现。当我在本地使用它时,它工作得很好,但在服务器上无法使其运行。

我的配置如下

我的回声设置 (Js/Bootstrap.js)

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    encrypted: false,
    wsHost: window.location.hostname,
    wsPort: 6001,
});
Run Code Online (Sandbox Code Playgroud)

我的推送器设置 (Broadcasting.php)

'pusher' => [
     'driver' => 'pusher',
     'key' => env('PUSHER_APP_KEY'),
     'secret' => env('PUSHER_APP_SECRET'),
     'app_id' => env('PUSHER_APP_ID'),
  'options' => [
     'cluster' => env('PUSHER_APP_CLUSTER'),
     'encrypted' => false,
     'host' => env('WEBSOCKET_HOST'),
     'port' => env('WEBSOCKET_PORT'),
     'scheme' => env('WEBSSOCKET_SCHEME'),
 ],
],
Run Code Online (Sandbox Code Playgroud)

我的 Webscoket 设置 (Websockets.php)

'dashboard' => [
       'port' => env('LARAVEL_WEBSOCKETS_PORT', 6001),
],

 'apps' => [
        [
            'id' => env('PUSHER_APP_ID'),
            'name' …
Run Code Online (Sandbox Code Playgroud)

websocket laravel server laravel-websockets

5
推荐指数
1
解决办法
1746
查看次数

带有 ssl 和 nginx 的 Laravel-websockets

我一直在尝试使用服务器上 nginx 上的 ssl 让 laravel-websockets 在我的网站上工作。我一直在使用 Laravel 和 echo。它在我的本地计算机上完美运行。

这是我在控制台中遇到的错误

WebSocket connection to 'wss://www.site.com:6001/app/passcode?protocol=7&client=js&version=4.3.1&flash=false' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
Run Code Online (Sandbox Code Playgroud)

这是我的文件

配置/广播.php


    /*
    |--------------------------------------------------------------------------
    | Default Broadcaster
    |--------------------------------------------------------------------------
    |
    | This option controls the default broadcaster that will be used by the
    | framework when an event needs to be broadcast. You may set this to
    | any of the connections defined in the "connections" array below.
    |
    | Supported: "pusher", "redis", "log", "null"
    |
    */

    'default' => env('BROADCAST_DRIVER', …
Run Code Online (Sandbox Code Playgroud)

nginx websocket laravel laravel-websockets

5
推荐指数
0
解决办法
1194
查看次数

Flutter + Laravel Websocket + Pusher 更换(代客安全)

我在Laravel 后端使用Beyondco Larevel Websockets,在 Flutter 前端使用pusher_clientlaravel_echo

我一直在尝试从我的 ios 模拟器连接到我的 Laravel 后端主机,它使用了代客安全,但失败了。

我的颤振连接:

PusherClient getPusherClient(String token) {
  PusherOptions options = PusherOptions(
      host: 'my-local-server.test',
      wsPort: 6001,
      wssPort: 6001,
      cluster: DotEnv.env['PUSHER_APP_CLUSTER'],
      encrypted: true,
      auth: PusherAuth('https://my-local-server.test/api/broadcasting/auth',
          headers: {'Authorization': 'Bearer $token'})
  );

  return PusherClient(DotEnv.env['PUSHER_APP_KEY'], options,
      enableLogging: true, autoConnect: false);
}
pusherClient = getPusherClient(token);
pusherClient.connect();
pusherClient.onConnectionStateChange((state) {
  print(
      "previousState: ${state.previousState}, currentState: ${state.currentState}");
});
pusherClient.onConnectionError((error) {
  print(error.message);
});
Run Code Online (Sandbox Code Playgroud)

https://my-local-server.test/laravel-websockets我从来没有看到来自 Flutter 的请求,但是如果我从我的 Laravel 后端触发一个事件,它会被记录下来。

请帮助我解决设置中的问题,为什么我无法从 Flutter 应用程序连接到运行 laravel-websocket 的 SSL …

laravel flutter laravel-echo laravel-websockets

5
推荐指数
0
解决办法
171
查看次数

Laravel GraphQl 出现无法连接到 websocket 端点错误

实现一个简单的GraphQl查询(例如 simple)MutationSubscription,当我尝试将其运行subscriptiongraphql-playground

subscription {
   userCreated{
     name
     username
     password
   }
}
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

{
  "error": "Could not connect to websocket endpoint ws://127.0.0.1:8000/graphql. 
Please check if the endpoint url is correct."
}
Run Code Online (Sandbox Code Playgroud)

GraphQl 架构:

#...
type User {
    id: Int!
    name: String
    email: String
    product : [Product!]
}

type Mutation {
 createUser(
    name: String!
    password: String!
    email : String!
  ): User @field(resolver:"UserMutator@create") @broadcast(subscription: "userCreated")
}

type Subscription {
  userCreated: User
}

Run Code Online (Sandbox Code Playgroud)

UserMutator班级: …

laravel graphql laravel-lighthouse laravel-websockets

5
推荐指数
0
解决办法
353
查看次数

通道当前状态在生产环境中的 Laravel WebSockets 中不可用 (Ubuntu 20.04.4)

我正在尝试在 larvel-9.0 项目上设置 websockets。当我尝试打开 /laravel-websockets 时,我在控制台中收到以下错误。项目在 Ubuntu 20.04.4 上安装。

Pusher.min.js:8 与 'wss://dev.mydomain.in:6001/app/mywebsocketkey?protocol=7&client=js&version=4.3.1&flash=false' 的 WebSocket 连接失败:

当我尝试通过带有 url 的邮递员连接它时,我收到成功响应

wss://dev.mydomain.in:6001/app/mywebsocketkey?protocol=7&client=js&version=4.3.1&flash=false

我在邮递员中收到以下回复。

{
    "event": "pusher:connection_established",
    "data": "{\"socket_id\":\"371175048.259495464\",\"activity_timeout\":30}"
}
Run Code Online (Sandbox Code Playgroud)

我遵循了Websockets 文档

这是broadcast.php配置

'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => env('PUSHER_APP_CLUSTER'),
                'useTLS' => true,
                'encrypted' => true,
                'host' => 'dev.mydomain.in',
                'port' => 6001,
                'scheme' => 'https',
                'curl_options' => [
                    CURLOPT_SSL_VERIFYHOST => 0,
                    CURLOPT_SSL_VERIFYPEER => 0,
                ]
            ], …
Run Code Online (Sandbox Code Playgroud)

php node.js laravel laravel-websockets

5
推荐指数
1
解决办法
4025
查看次数

如何从除 laravel-echo 之外的其他客户端连接到 laravel soketi?

我正在使用 laravel soketi 包。我不想使用 laravel-echo 进行客户端连接。所以,我正在用 firecamp 进行测试。但无法连接。

Soketi 已启动并运行

  Server is up and running!
    The Websockets server is available at 127.0.0.1:6001
    The HTTP API server is available at http://127.0.0.1:6001
    The /usage endpoint is available on port 9601.
Run Code Online (Sandbox Code Playgroud)

在 firecamp 中连接时我使用 url asws://localhost:6001/ 但无法连接。 在此输入图像描述

那么,如何连接呢?

laravel uwebsockets laravel-websockets

5
推荐指数
0
解决办法
463
查看次数