@@ -38,7 +38,7 @@ class Socket extends EventEmitter {
3838 // eslint-disable-next-line no-async-promise-executor
3939 return new Promise ( async ( resolve , reject ) => {
4040 try {
41- await this . _connect ( address ) ;
41+ await this . _connect ( address , Boolean ( args . secure ) ) ;
4242 await this . _authenticate ( args . password ) ;
4343 resolve ( ) ;
4444 } catch ( err ) {
@@ -53,17 +53,17 @@ class Socket extends EventEmitter {
5353 /**
5454 * Opens a WebSocket connection to an obs-websocket server, but does not attempt any authentication.
5555 *
56- * @param {String } address url without ws:// prefix.
56+ * @param {String } address url without ws:// or wss:// prefix.
5757 * @returns {Promise }
5858 * @private
5959 * @return {Promise } on attempted creation of WebSocket connection.
6060 */
61- async _connect ( address ) {
61+ async _connect ( address , secure ) {
6262 return new Promise ( ( resolve , reject ) => {
6363 let settled = false ;
6464
65- debug ( 'Attempting to connect to: %s' , address ) ;
66- this . _socket = new WebSocket ( ' ws://' + address ) ;
65+ debug ( 'Attempting to connect to: %s (secure: %s) ' , address , secure ) ;
66+ this . _socket = new WebSocket ( ( secure ? 'wss://' : ' ws://') + address ) ;
6767
6868 // We only handle the initial connection error.
6969 // Beyond that, the consumer is responsible for adding their own generic `error` event listener.
0 commit comments