在Kubernetes吊舱中,can';t强制Laravel Echo(使用Pusher)通过端口6001上的ws协议而不是端口443上的wss进行连接

在Kubernetes吊舱中,can';t强制Laravel Echo(使用Pusher)通过端口6001上的ws协议而不是端口443上的wss进行连接,laravel,websocket,echo,pusher,Laravel,Websocket,Echo,Pusher,我很难弄清楚如何将我们的Laravel应用程序连接到端口6001上托管的websockets服务器。在我的本地机器上一切都正常,但当我在Kubernetes上部署时,控制台中出现以下错误: Pusher : : ["Connecting",{"transport":"ws","url":"wss://localhost:443/app/[redacted]?protocol=7&client=js&version=5.1.1&flash=false"}] app.js:

我很难弄清楚如何将我们的Laravel应用程序连接到端口6001上托管的websockets服务器。在我的本地机器上一切都正常,但当我在Kubernetes上部署时,控制台中出现以下错误:

Pusher :  : ["Connecting",{"transport":"ws","url":"wss://localhost:443/app/[redacted]?protocol=7&client=js&version=5.1.1&flash=false"}]
app.js:1 WebSocket connection to 'wss://localhost/app/[redacted]?protocol=7&client=js&version=5.1.1&flash=false' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
Pusher报告的url是
wss://localhost:443
,但实际连接正在尝试
wss://localhost
端口上的
:80

此外,我已经明确设置了
启用传输:['ws']
,并且没有提供
wssHost
wssPort

此外,由于此连接发生在Kubernetes吊舱内,因此我已采取了所有步骤禁用SSL。以下是我的配置:

config/websockets.php:

...
    'apps' => [
        [
            'id' => env('PUSHER_APP_ID'),
            'name' => env('APP_NAME'),
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'path' => env('PUSHER_APP_PATH'),
            'capacity' => null,
            'enable_client_messages' => false,
            'enable_statistics' => true,
        ],
    ],
...
resources/js/store/state.js

...
import Echo from 'laravel-echo'
/**
 * Echo exposes an expressive API for subscribing to channels and listening
 * for events that are broadcast by Laravel. Echo and event broadcasting
 * allows your team to easily build robust real-time web applications.
 */

window.Pusher = require('pusher-js');
window.Pusher.logToConsole = true;

let state = {
        ads:{},
        latestAds: [],
        selectedAds: [],
        partCodes:[],
        carCodes:[],
        echo: new Echo({
            broadcaster: 'pusher',
            key: [redacted],
            wsHost: 'localhost',
            wsPort: 6001,
            disableStats: true,
            enabledTransports: ['ws'], // <- added this param
            auth: {
                headers: {
                    Authorization: 'Bearer ' + localStorage.getItem('admanager-token'),
                    'X-CSRF-Token': "CSRF_TOKEN"
                }
            },
            'cluster': 'eu',
        })

    }

export default state
...
。。。
从“laravel Echo”导入回音
/**
*Echo公开了一个用于订阅频道和监听的表现性API
*对于由Laravel广播的事件。回声和事件广播
*允许您的团队轻松构建健壮的实时web应用程序。
*/
window.Pusher=require('Pusher-js');
window.Pusher.logToConsole=true;
让状态={
广告:{},
最新状态:[],
所选数据:[],
零件代码:[],
车辆代码:[],
回声:新回声({
广播员:“推手”,
关键字:[已编辑],
wsHost:'localhost',
wsPort:6001,
disableStats:正确,
EnabledTransport:['ws'],//在您的config/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'),
                'useTLS' => false,
                'host' => '127.0.0.1',
                'port' => 6001,
                'scheme' => 'http',
                'encrypted' => false,
            ],
        ],
在前端时,确保三个组件同步:

  • wsHost
  • 无线端口
  • 和应用程序密钥
在config/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'),
                'useTLS' => false,
                'host' => '127.0.0.1',
                'port' => 6001,
                'scheme' => 'http',
                'encrypted' => false,
            ],
        ],
在前端时,确保三个组件同步:

  • wsHost
  • 无线端口
  • 和应用程序密钥