SocketCluster/socketcluster-client

Docs & readme incorrect on "rejectUnauthorized"

jianyuanw opened this issue · 3 comments

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 }
};

@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)?

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

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