config目錄多了一個plugin.php的配置文件,這個文件里的部分配置恰巧會影響的push文件中的端口號 導致websocket無法連接
我已經(jīng)刪除了該文件 慎用config/plugin.php的配置 最好不要去定義他
以前也做過了很多次了 今天新的項目死活連不上 用老項目現(xiàn)在也連不上 沒轍了
希望大佬幫我看看是哪的問題
//app.php
[
'enable' => true,
'websocket' => 'websocket://0.0.0.0:3131',
'api' => 'http://0.0.0.0:3232',
'app_key' => 'xxxxx',
'app_secret' => 'xxxxxxx',
'channel_hook' => 'http://127.0.0.1:8787/plugin/webman/push/hook',
'auth' => '/plugin/webman/push/auth'
]
//process.php
[
'server' => [
'handler' => Server::class,
'listen' => config('plugin.webman.push.app.websocket'),
'count' => 1, // 必須是1
'reloadable' => false, // 執(zhí)行reload不重啟
'constructor' => [
'api_listen' => config('plugin.webman.push.app.api'),
'app_info' => [
config('plugin.webman.push.app.app_key') => [
'channel_hook' => config('plugin.webman.push.app.channel_hook'),
'app_secret' => config('plugin.webman.push.app.app_secret'),
],
]
]
]
]
//nginx
upstream webman {
server 127.0.0.1:8795;
keepalive 10240;
}
location ^~ / {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
proxy_set_header Connection "";
if (!-f $request_filename){
proxy_pass http://webman;
}
}
location ~ "^/app/[a-zA-Z0-9_-]{16,32}$" {
proxy_pass http://127.0.0.1:3131;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Real-IP $remote_addr;
}
//連接代碼
var webman_push = new Push({
url: 'ws://' + window.location.hostname,
app_key: 'bbaa660689dc6546f237056ac495af3e',
auth: '/plugin/webman/push/auth' // 訂閱鑒權(quán)(僅限于私有頻道)
});
push.js:245 WebSocket connection to 'ws://yingshi.com/app/bbaa660689dc6546f237056ac495af3e' failed:
這里寫具體的系統(tǒng)環(huán)境相關(guān)信息
docker環(huán)境 外部開啟了8795端口
location ^~ / {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
proxy_set_header Connection "";
if (!-f $request_filename){
proxy_pass http://webman;
}
}
location ^~ /app/bbaa660689dc6546f237056ac495af3e
{
proxy_pass http://127.0.0.1:8796;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Real-IP $remote_addr;
}
[
'enable' => true,
'websocket' => 'websocket://0.0.0.0:8788',
'api' => 'http://0.0.0.0:3232',
'app_key' => 'b29cddbecf88bae109698855d5d52b3a',
'app_secret' => '309015f9348a53422523764e095a8bdd',
'channel_hook' => 'http://127.0.0.1:8787/plugin/webman/push/hook',
'auth' => '/plugin/webman/push/auth'
]
var connection = new Push({
url: 'ws://' + '127.0.0.1:8788',
app_key: 'b29cddbecf88bae109698855d5d52b3a',
auth: '/plugin/webman/push/auth' // 訂閱鑒權(quán)(僅限于私有頻道)
});
var private_channel = connection.subscribe('private-admin-channel')
private_channel.on('message', function (data) {
console.log(data)
});