websocket over http (nginx) @ 071's blog :: 隨意窩 Xuite日誌
    1. 沒有新回應!
  • 201912270958websocket over http (nginx)

     

    //etc/nginx/nginx.conf

    // 8086 is websocket server port, nginx will proxy to websocket server(8086) when header connection contain "upgrade"

    location /wsapp {
    auth_digest off;
    proxy_pass http://127.0.0.1:8086;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    }

     

    // html , test webscoket client

    <script>
    var ws = new WebSocket('wss://10.50.1.56/wsapp','my-cgi-protocol');
    ws.onopen = function() {
    document.body.style.backgroundColor = '#cfc';
    console.log("onopen");
    ws.send('livetime&eventinfo')
    };
    ws.onclose = function() {
    document.body.style.backgroundColor = null;
    console.log("onclose");
    };
    ws.onmessage = function(event) {
    console.log("onmessage:"+event.data);
    document.getElementById('count').textContent = event.data;
    };
    </script>

    C# : zip extrac...|日誌首頁|C# OutputDebugS...上一篇C# : zip extract zip into a folder/ save a folder into a zip file...下一篇C# OutputDebugString for DebugTrack...
    回應