         attachWebSocketHandlers()
         websocket?.connect()
         #else
-        try? WebSocket.background(to: connectURL) {[weak self] ws in
+        let uri = URI(hostname: connectURL)
+        try? WebSocket.background(to: uri,
+                                  using: TCPInternetSocket(scheme: uri.scheme,
+                                                           hostname: uri.hostname,
+                                                           port: uri.port ?? 80)) {[weak self] ws in
             guard let this = self else { return }
             DefaultDiscordLogger.Logger.log("Websocket connected, shard: \(this.description)", type: "DiscordWebSocketable")
 

import Starscream
#else
import WebSockets
#endif

/// Declares that a type will be an Engine for the Discord Gateway.


            DefaultDiscordLogger.Logger.log("WebSocket closed, \(this.description)", type: "DiscordWebSocketable")

            this.handleClose(reason: nil)
        }
        #endif
    }
