小编Sha*_*Ali的帖子

如何从JavaScript调用REST Web服务API?

我有一个HTML页面,上面有一个按钮.当我点击该按钮时,我需要调用Rest Web Service API?我试着到处搜索.毫无头绪.有人可以给我一个领导/ Headstart吗?非常感谢

html javascript rest web-services

124
推荐指数
5
解决办法
41万
查看次数

创建安全 Websocket 连接时,客户端网络套接字在建立安全 TLS 连接之前已断开连接错误

我正在尝试创建一个安全的 websocket 客户端和服务器。

服务器代码:

var options = { 
    key: clientKey, 
    cert: clientCert, 
    ca: caCert,
    passphrase: 'test',
    requestCert: true
}; 

var httpsServer = https.createServer(options);

var WebSocketServer = WebSocket.Server;
var wss = new WebSocketServer({
        verifyClient: (info) => {
            console.log('Request from client :'+ info.req.rawHeaders);
            console.log('Request from client auth :'+ info.req.client.authorized);
            success = !!info.req.client.authorized;
            return success;
        },
        server: httpsServer
});
Run Code Online (Sandbox Code Playgroud)

客户端代码:

const ws = new WebSocket('wss://localhost:8989/',
          'com.hp.cdm.service.ioFilter.version.1.type.filterStream', {
            cert: fs.readFileSync(path.normalize(serverCertPath)),
            key: fs.readFileSync(path.normalize(serverKeyPath)),
            ca: fs.readFileSync(path.normalize(caCert)),
            passphrase: 'test',
            rejectUnauthorized: false,
          });
Run Code Online (Sandbox Code Playgroud)

当我尝试从客户端到服务器建立连接时,出现以下错误:

{ Error: Client network …
Run Code Online (Sandbox Code Playgroud)

ssl https websocket node.js

7
推荐指数
0
解决办法
3616
查看次数

标签 统计

html ×1

https ×1

javascript ×1

node.js ×1

rest ×1

ssl ×1

web-services ×1

websocket ×1