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
  • 相关阅读:
    pymongo 常用方法
    字典判断是否具备 key
    flask中的request和常用属性方法
    zipfile 解压,py3 win下中文乱码
    远程登录mongo
    eval
    二分查找
    快速排序
    Python3解leetcode Single Number
    Python3解leetcode Best Time to Buy and Sell Stock II
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/7866122.html
Copyright © 2011-2022 走看看