Can socket.io-client use https?
See original GitHub issueCan socket.io-client use https?
connect does not run.
Is option missing?
//設定ファイルの読み込み
require('dotenv').config();
var fs = require('fs');
var ssl_server_key = '../../ssl/new_server.key';
var ssl_server_crt = '../../ssl/server.crt';
var options = {
key: fs.readFileSync(ssl_server_key),
cert: fs.readFileSync(ssl_server_crt),
pfx: fs.readFileSync(ssl_server_crt),
passphrase: process.env.HTTPS_PASS
};
//socket.io-clientでサーバへ接続
var client = require('socket.io-client');
var socket = client.connect('https://localhost:30000/namespace',options);
//処理
//connectしたら'how are you?'とメッセージを送信する
socket.on('connect',function(){
console.log('yea!!');
socket.send('how are you?');
socket.disconnect();
process.exit(0);
});
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
node.js, socket.io with SSL - Stack Overflow
Use a secure URL for your initial connection, i.e. instead of "http://" use "https://". If the WebSocket transport is chosen, then Socket.
Read more >Server Initialization | Socket.IO
Once you have installed the Socket.IO server library, you can now init the server. The complete list of options can be found here....
Read more >Create a Secure Chat Application with Socket.IO and React
This tutorial shows you how to create a real-time chat application using JavaScript and Socket.IO.
Read more >socket.io-client - npm
Start using socket.io-client in your project by running `npm i socket.io-client`. ... The source code of the website can be found here.
Read more >Encrypted Websockets with Express and Socket.io
Everything must be encrypted over an HTTPS webpage, including Websocket connections. Major browsers like Safari block insecure Websocket connections on ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is important.
options = { secure:true, reconnect: true, rejectUnauthorized : false };
Thank you.
Example added here: https://socket.io/docs/v3/client-initialization/#Node-js-specific-options
Client
Server