• 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
  • 相关阅读:
    hadoop生态--ElasticSearch--ES操作
    Haoop生态--ElasticSeaarch(1)--ES预备知识(全文检索的概念、Lucence、倒排索引)
    hadoop生态--Hive(2)--Hive的使用方式
    hadoop生态--Zookeeper
    gsoap使用
    set容器
    如何杀死defunct进程
    关于多态
    数组类型与函数指针基本语法知识
    syslog日志
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/7866122.html
Copyright © 2020-2023  润新知