SocketCluster / socketcluster-client

JavaScript client for SocketCluster
MIT License
290 stars 92 forks source link

Docs & readme incorrect on "rejectUnauthorized" #151

Closed jianyuanw closed 10 months ago

jianyuanw commented 10 months ago

SocketCluster client version 17.2.2

Node.js v18

Docs: https://socketcluster.io/docs/api-socket-cluster-client/ Readme: https://github.com/SocketCluster/socketcluster-client#readme

To connect to a secure SocketCluster server using a self-signed certificate, docs and readme indicated the following way.

let options = {
  hostname: 'securedomain.com',
  secure: true,
  port: 443,
  rejectUnauthorized: false
};

let socket = socketClusterClient.create(options);

However, I was not able to connect and there was no error message.

Upon looking into the source code, I found that rejectUnauthorized has to be wrapped within a wsOptions property, as follows.

let options = {
  hostname: 'securedomain.com',
  secure: true,
  port: 443,
  wsOptions: { rejectUnauthorized: false }
};
jondubois commented 10 months ago

@jianyuanw Thanks for pointing this out. This was changed at some point and docs were not updated to match. Will update soon. Were you running the socketcluster-client inside Node.js (not in the browser)?

jianyuanw commented 10 months ago

Yes, I was running it in Node.js. Thanks!

jondubois commented 10 months ago

Ok, I updated the docs. Thanks again for reporting this.