国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

nginx 反向代理 workerman的 websocket 一直連接不上

zxd1021


服務(wù)端代碼是這么寫的

<?php

include __DIR__ . '/workerman/Autoloader.php';
use Workerman\Worker;
// 這里設(shè)置的是websocket協(xié)議(端口任意,但是需要保證沒(méi)被其它程序占用)
$worker = new Worker('websocket://0.0.0.0:1010');
// 設(shè)置transport開啟ssl,websocket+ssl即wss
//$worker->transport = 'ssl';
$worker->onMessage = function($connection, $data)
{
    $connection->send("hello");
};

Worker::runAll();

下面是 nginx的配置文件

server {
    listen 80;
    server_name xxxxxxxxxxxxxx;
    rewrite ^(.*)$ https://$host$1 permanent;
}
server {
        listen  443 ssl;
        server_name  xxxxxxxxxxxxxx;
        index index.html index.htm index.php;

        ssl on;
        ssl_certificate  /data/home/server/nginx-1.7/conf/ssl/xxxxxxxxxxxxxx/xxxxxxxxxxxxxx.pem;
        ssl_certificate_key /data/home/server/nginx-1.7/conf/ssl/xxxxxxxxxxxxxx/xxxxxxxxxxxxxx.key;
        ssl_session_timeout 5m;
        ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
        ssl_protocols SSLv3 SSLv2 TLSv1 TLSv1.1 TLSv1.2;
        ssl_session_cache shared:SSL:50m;
        ssl_prefer_server_ciphers on;
        location / {
            root /data/home/www/xxxxxxxxxxxxxx/public;
            index  index.php index.html index.htm;
            # Nginx環(huán)境配置,隱藏ThinkPHP public index.php入口
            #try_files $uri $uri/ /index.php?s=$uri&$args;
            try_files $uri $uri/ /index.php?s=$args;
            if (!-e $request_filename) {
                    rewrite  ^(.*)$  /index.php?s=/$1  last;
                    break;
            }
            }
            #error_page  404              /404.html;
            # redirect server error pages to the static page /50x.html
            #
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
            # proxy the PHP scripts to Apache listening on 127.0.0.1:80
            #
            #location ~ \.php$ {
            #    proxy_pass   http://127.0.0.1;
            #}
            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            #
              location /wss
              {
                      proxy_pass http://127.0.0.1:8686;
                      proxy_set_header X-Real-IP $remote_addr;
                      proxy_set_header Host $host;
                      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                      proxy_http_version 1.1;
                      proxy_set_header Upgrade $http_upgrade;
                      proxy_set_header Connection "upgrade";
                      proxy_redirect off;
              }
            location ~ \.php { #去掉$
                root /data/home/www/xxxxxxxxxxxxxx/public;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
            fastcgi_split_path_info ^(.+\.php)(.*)$;     #增加這一句
            fastcgi_param PATH_INFO $fastcgi_path_info;    #增加這一句
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }
#   include /alidata/server/nginx/conf/rewrite/phpmyadmin.conf;
    #access_log  /alidata/log/nginx/access/phpmyadmin.log;
}

這個(gè)啟動(dòng)完的顯示

----------------------- WORKERMAN -----------------------------
Workerman version:3.5.14          PHP version:7.0.0
------------------------ WORKERS -------------------------------
proto    user          worker        listen                      processes status
tcp      root          none          websocket://127.0.0.1:8686   4          
----------------------------------------------------------------
Press Ctrl+C to stop. Start success.

網(wǎng)頁(yè)代碼

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1" />
    <title>撒的發(fā)撒的發(fā)</title>
</head>
<body class="gray-bg">
<script language="javascript">
    ws = new WebSocket("wss://xxxxxxxxxx/wss");
    ws.onopen = function() {
        alert("連接成功");
        ws.send('tom');
        alert("給服務(wù)端發(fā)送一個(gè)字符串:tom");
    };
    ws.onmessage = function(e) {
        alert("收到服務(wù)端的消息:" + e.data);
    };
    ws.onerror = function(e) {
        console.log(e);
    };
</script>
</body>
</html>

一直連接超時(shí)504

14439 11 0
11個(gè)回答

zxd1021

WebSocket connection to 'wss://xxxxxxx/wss' failed: Error during WebSocket handshake: Unexpected response code: 504

瀏覽器拋出的是這個(gè)錯(cuò)誤提示,我排查了一下有可能是通訊協(xié)議的問(wèn)題,但是我實(shí)在是不知道怎么改

  • 暫無(wú)評(píng)論
zxd1021

上面寫錯(cuò)的端口號(hào)也調(diào)整成一致了,并沒(méi)有什么卵用

  • 暫無(wú)評(píng)論
walkor 打賞

按照手冊(cè)把nginx多余的配置去掉試下,沒(méi)問(wèn)題了再把nginx一點(diǎn)一點(diǎn)加回來(lái)看下是哪里問(wèn)題

  • zxd1021 2018-09-05

    大神我用的是 nginx1.7版本 跟手冊(cè)一樣的配置是報(bào)404的,然后我就 加 了server_name 之后變成504錯(cuò)誤 腦殼疼

  • zxd1021 2018-09-05

    大神我現(xiàn)在在社區(qū)里面找配置文件照著改,然而一直是301 502 504 這三個(gè)直接徘徊

  • zxd1021 2018-09-05

    我現(xiàn)在的有一些疑問(wèn)就是 這個(gè)對(duì)nginx的版本有要求嗎,然后還有就是支持跨域嗎,

  • walkor 2018-09-05

    根據(jù)手冊(cè),nginx 版本不能小于1.3

  • zxd1021 2018-09-05

    那我滿足了 我的版本是1.7的 其次跨域的那個(gè)現(xiàn)在不用考慮 最后各種姿勢(shì)的配置文件我也嘗試過(guò)了但就是gg 各種504 是我臉黑嗎 還是我姿勢(shì)不對(duì)=.=

  • walkor 2018-09-05

    把你現(xiàn)在的配置貼出來(lái)

  • zxd1021 2018-09-05

    好的 稍等

  • zxd1021 2018-09-05

    發(fā)出來(lái)了

zxd1021
server {
    listen 443 ssl;
    server_name xxxxxx.com;
    root /data/home/www/songshihuishou/public;

    ssl on;
    ssl_certificate  /data/home/server/nginx-1.7/conf/ssl/1537639025967/1537639025967.pem;
    ssl_certificate_key /data/home/server/nginx-1.7/conf/ssl/1537639025967/1537639025967.key;
    ssl_session_timeout 5m;
    ssl_session_cache shared:SSL:50m;
    ssl_protocols SSLv3 SSLv2 TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;

    location /wss
    {
        proxy_pass http://127.0.0.1:8282;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header X-Real-IP $remote_addr;
    }
}
  • 暫無(wú)評(píng)論
walkor 打賞

workerman 的
php start.php status 貼下

zxd1021
<?php
include __DIR__ . '/workerman/Autoloader.php';
use Workerman\Worker;
if(strpos(strtolower(PHP_OS), 'win') === 0)
{
    exit("start.php not support windows, please use start_for_win.bat\n");
}

// 標(biāo)記是全局啟動(dòng)
define('GLOBAL_START', 1);
// 這里設(shè)置的是websocket協(xié)議(端口任意,但是需要保證沒(méi)被其它程序占用)
$ws_worker = new Worker('websocket://0.0.0.0:8282');
// 設(shè)置transport開啟ssl,websocket+ssl即wss
//$ws_worker->transport = 'ssl';
// 啟動(dòng)4個(gè)進(jìn)程對(duì)外提供服務(wù)
$ws_worker->count = 4;
// 當(dāng)收到客戶端發(fā)來(lái)的數(shù)據(jù)后返回hello $data給客戶端
$ws_worker->onMessage = function($connection, $data){
    // 向客戶端發(fā)送hello $data
    $connection->send('hello ');
};

Worker::runAll();

這個(gè)是后端的代碼

  • 暫無(wú)評(píng)論
zxd1021
Workerman status 
----------------------------------------------GLOBAL STATUS----------------------------------------------------
Workerman version:3.5.14          PHP version:7.0.0
start time:2018-09-05 09:58:08   run 0 days 0 hours   
load average: 0, 0, 0            event-loop:\Workerman\Events\Select
1 workers       4 processes
worker_name  exit_status      exit_count
none         0                0
----------------------------------------------PROCESS STATUS---------------------------------------------------
pid memory  listening                worker_name  connections send_fail timers  total_request qps    status
19991   2M      websocket://0.0.0.0:8282 none         0           0         0       0             0      
19992   2M      websocket://0.0.0.0:8282 none         0           0         0       0             0      
19993   2M      websocket://0.0.0.0:8282 none         0           0         0       0             0      
19994   2M      websocket://0.0.0.0:8282 none         0           0         0       0             0      
----------------------------------------------PROCESS STATUS---------------------------------------------------
Summary 8M      -                        -            0           0         0       0             0       
  • 暫無(wú)評(píng)論
walkor 打賞

客戶端連接代碼發(fā)下,我測(cè)試下,不要隱藏域名

walkor 打賞

看下你的服務(wù)器

server {
listen 443 ssl;
server_name xxxxxx.com;

xxxxxx.com是什么

  • 暫無(wú)評(píng)論
walkor 打賞

還有看下是不是用了cdn

  • zxd1021 2018-09-05

    好像是的,用了cdn 中間隔了個(gè)服務(wù)器

  • zxd1021 2018-09-05

    我朋友給我解析的 打開直接就是https 應(yīng)該是用了cdn

  • zxd1021 2018-09-05

    感謝大神,真的是用了cdn, 等解析生效了我在試試 三克油

  • zxd1021 2018-09-05

    雖然被cdn卡了一天,但是解決了 很美滋滋 謝謝大神

  • walkor 2018-09-05

    不客氣

且聽風(fēng)吟

多謝多謝,我這邊也碰到類似的問(wèn)題,我的域名解析也用了cdn,請(qǐng)問(wèn)你是怎么解決的?

  • 云上屹立君 2018-12-12

    我也是這個(gè)問(wèn)題,老哥,求解決方案啊。

  • 君君 2019-02-19

    老哥,求解決方案

年代過(guò)于久遠(yuǎn),無(wú)法發(fā)表回答
??