discord: Could not open socket to "gateway.discord.gg:443"
I tried running php artisan discord:setup and got this output:
Is the bot already added to your server? (yes/no) [no]:
>
What is your Discord app client ID?:
> <client_id>
Add the bot to your server by visiting this link: https://discordapp.com/oauth2/authorize?&client_id=<client_id>&scope=bot&permissions=0
Continue? (yes/no) [yes]:
>
Attempting to identify the bot with Discord's websocket gateway...
Could not get a websocket gateway address, defaulting to 'wss://gateway.discord.gg'.
Connecting to 'wss://gateway.discord.gg'...
WebSocket\ConnectionException : Could not open socket to "gateway.discord.gg:443": (0).
at S:\repos\totoro\vendor\textalk\websocket\lib\Client.php:60
56| // Open the socket. @ is there to supress warning that we will catch in check below instead.
57| $this->socket = @fsockopen($host_uri, $port, $errno, $errstr, $this->options['timeout']);
58|
59| if ($this->socket === false) {
> 60| throw new ConnectionException(
61| "Could not open socket to \"$host:$port\": $errstr ($errno)."
62| );
63| }
64|
Exception trace:
1 WebSocket\Client::connect()
S:\repos\totoro\vendor\textalk\websocket\lib\Base.php:30
2 WebSocket\Base::send("{"op":2,"d":{"token":"<bot api token>","v":3,"compress":false,"properties":{"$os":"WINNT","$browser":"laravel-notification-channels-discord","$device":"laravel-notification-channels-discord","$
referrer":"","$referring_domain":""}}}")
S:\repos\totoro\vendor\laravel-notification-channels\discord\src\Commands\SetupCommand.php:96
Please use the argument -v to see more details.
Could this happen because the gateway version is too old? I had a quick look at the discord dev portal and saw the latest version is 6, not 3 as used in the request.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (16 by maintainers)
This actually seems to be an issue not specific to
textalk/websocket, but has been discussed in Textalk/websocket-php#50, and seems a solution would be to disableverify_peerandverify_peer_nameon the context. Possible solution:Okay, so that’s why it’s returning a
400. You can get your Discord user ID by turning on developer mode in theAdvancedsection of theAppearancesettings window and then right-clicking your username in the user list of a server and selectingCopy ID. I’ll go ahead and add some clarification to the README as well as the method documentation on what exactly should be passed in.