@@ -38,7 +38,7 @@ class Socket extends EventEmitter {
38
38
// eslint-disable-next-line no-async-promise-executor
39
39
return new Promise ( async ( resolve , reject ) => {
40
40
try {
41
- await this . _connect ( address ) ;
41
+ await this . _connect ( address , Boolean ( args . secure ) ) ;
42
42
await this . _authenticate ( args . password ) ;
43
43
resolve ( ) ;
44
44
} catch ( err ) {
@@ -53,17 +53,17 @@ class Socket extends EventEmitter {
53
53
/**
54
54
* Opens a WebSocket connection to an obs-websocket server, but does not attempt any authentication.
55
55
*
56
- * @param {String } address url without ws:// prefix.
56
+ * @param {String } address url without ws:// or wss:// prefix.
57
57
* @returns {Promise }
58
58
* @private
59
59
* @return {Promise } on attempted creation of WebSocket connection.
60
60
*/
61
- async _connect ( address ) {
61
+ async _connect ( address , secure ) {
62
62
return new Promise ( ( resolve , reject ) => {
63
63
let settled = false ;
64
64
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 ) ;
67
67
68
68
// We only handle the initial connection error.
69
69
// Beyond that, the consumer is responsible for adding their own generic `error` event listener.
0 commit comments