This is a problem with your client side. If you look in the module ws. Upstairs you
const closeTimeout = 30 * 1000;
And then you have the code below
if (!this._finalized) {
if (this._closeFrameReceived) this._socket.end();
this._closeTimer = setTimeout(this._finalize, closeTimeout, true);
}
, 30 . const, configurable . , , ws.finalize() ws.close()
const WebSocket = require('ws');
let ws = new WebSocket("wss://127.0.0.1:8999/", {
rejectUnauthorized: false
});
ws.onopen = function() {
console.log("Connected to WebSocket server");
};
ws.onmessage = function(e) {
};
ws.onclose = function() {
console.log("Disconnected from WebSocketServer");
};
function disconnect() {
console.log("Disconnecting from WebSocketServer");
ws.close();
ws.finalize();
}
setTimeout(disconnect, 100)
Edit-1
, ws4py , rfc6455.
NodeJS, \x88\x80, , . ws4py/streaming.py , . , . 30- .
, python, . NodeJS WebSocket.server, .
NodeJS? ,
https://github.com/websockets/ws/blob/master/examples/ssl.js
'use strict';
const https = require('https');
const fs = require('fs');
const WebSocket = require('..');
const server = https.createServer({
cert: fs.readFileSync('../test/fixtures/certificate.pem'),
key: fs.readFileSync('../test/fixtures/key.pem')
});
const wss = new WebSocket.Server({ server });
wss.on('connection', function connection (ws) {
ws.on('message', function message (msg) {
console.log(msg);
});
});
server.listen(function listening () {
const ws = new WebSocket(`wss://localhost:${server.address().port}`, {
rejectUnauthorized: false
});
ws.on('open', function open () {
ws.send('All glory to WebSockets!');
});
});