Blogger Information
Blog 143
fans 1
comment 0
visits 440334
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Nodejs搭建wss服务器
弘德誉曦的博客
Original
4447 people have browsed it


   Nodejs搭建wss服务器    

           

首先使用OpenSSL创建自签名证书:

复制代码
 > /path/to/- -key /path/to/.pem --req -days  - csr.pem -signkey /path/to/.pem - /path/to/file.crt
复制代码

使用ws模块创建wss服务器:

复制代码
 https=require( ws=require( fs=require( keypath=process.cwd()+; certpath=process.cwd()+;
  options = server=https.createServer(options, function (req, res) {
    res.writeHead();
    res.end( wss =  ws.Server( { server: server } );wss.on(
复制代码

客户端链接:

 ws =  WebSocket(

 

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post