zoukankan      html  css  js  c++  java
  • Nchan 安装试用(openresty 同时支持)

    备注:
       
       使用nginx最新的源码包(nginx-1.13.6),以及源码安装
     
    1. 下载源码包(nginx+ Nchan)
    https://nginx.org/download/nginx-1.13.6.tar.gz
    wget https://github.com/slact/nchan/archive/v1.1.10.zip
    2. 配置安装(对于需要的依赖按照提示即可)
    ./configure  --add-module=/opt/nginx/nchan-1.1.10
    make  && make install 
    3. 检验模块安装
    sbin/nginx -V
    nginx version: nginx/1.13.6
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) 
    configure arguments: --add-module=/opt/nginx/nchan-1.1.10
    3. 使用
       location = /sub {
          nchan_subscriber;
          nchan_channel_id $arg_id;
        }
        
        location = /pub {
          nchan_publisher;
          nchan_channel_id $arg_id;
        }
    4. 测试
    // http post data 
    
    curl 
      -H "Content-type: application/json" 
      -d '{"name": "dalong","age":333}' 
      'http://xxxxx:9090/pub?id=demo'
    
    // browser recived data
    var ws =new WebScoket("ws://xxxxx:9090/sub?id=demo")
    ws.onmessage=funciton(data){
       console.log(data)
    
    }
    效果
     
     
    5. 总结
    目前只是简答是试用,功能上还是比较强大的,对于安全的问题,参考文档有说明。
    同时经过测试openresty 编译也是支持的,很好很强大,在实时web开发上我们又有了
    比较方便的工具,同时减少了大家的工作量。
    6. 参考文档
    https://nchan.io/#install
    https://nginx.org/en/download.html
    https://github.com/slact/nchan
  • 相关阅读:
    大小端表示法
    构建二叉树并求其深度
    输入一行字符反向输出
    C++读取一行字符串输入
    关于递归调用的深度
    2016-9-22题目:extern char* 与char[]
    Ubuntu安装搜狗输入法
    判断字符串相等
    [Warning] deprecated conversion from string constant to 'char*' 原因
    ArcGIS API for JavaScript 4.2学习笔记[31] (补充学习)Task类
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/7866122.html
Copyright © 2011-2022 走看看