v icon indicating copy to clipboard operation
v copied to clipboard

websocket client connection in windows

Open MARCROCK22 opened this issue 8 months ago • 1 comments

Describe the bug

When I try to connect to discord's websocket, after reading the first event, i get Could not read using SSL.

Reproduction Steps

create a main.v

module main

import net.websocket as socket

fn main() {
	opt := socket.ClientOpt{}
	mut client := socket.new_client('wss://gateway.discord.gg/?v=10&encoding=json', opt)!

	client.connect()!

	client.on_message(fn (mut client socket.Client, msg &socket.Message) ! {
		eprintln('Received message: ${msg.payload.bytestr()}')
	})

	client.on_close(fn (mut client socket.Client, code int, reason string) ! {
		eprintln('Connection closed: code=${code}, reason=${reason}')
	})

	client.listen() or {
		eprintln('Error listening to messages: ${err}')
		return
	}
}

v run main.v

Expected Behavior

It keeps listening the events correcly.

Current Behavior

$ v run main.v
2025-06-13T23:07:48.956000Z [INFO ] connecting to host wss://gateway.discord.gg/?v=10&encoding=json
2025-06-13T23:07:49.158000Z [INFO ] successfully connected to host wss://gateway.discord.gg/?v=10&encoding=json
2025-06-13T23:07:49.159000Z [INFO ] Starting client listener, server(false)...
Received message: {"t":null,"s":null,"op":10,"d":{"heartbeat_interval":41250,"_trace":["[\"gateway-prd-us-east1-d-jf0t\",{\"micros\":0.0}]"]}}
2025-06-13T23:07:49.720000Z [INFO ] Quit client listener, server(false)...
Connection closed: code=1000, reason=closed by client
Error listening to messages: Could not read using SSL

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.10 6a3f12d

Environment details (OS name and version, etc.)

Detected v.mod file inside the project directory. Using it... |V executable |C:\Users\marco\Desktop\bins\v\v.exe |V last modified time|2025-06-13 23:03:51 | | |V home dir |OK, value: C:\Users\marco\Desktop\bins\v |VMODULES |OK, value: C:\Users\marco.vmodules |VTMP |OK, value: C:\Users\marco\AppData\Local\Temp\v_0 |Current working dir |OK, value: C:\Users\marco\Desktop\vlang\learning | | |Git version |git version 2.47.0.windows.2 |V git status |6a3f12d5 |.git/config present |true | | |cc version |N/A |gcc version |N/A |clang version |N/A |msvc version |N/A |tcc version |tcc version 0.9.27 (x86_64 Windows) |tcc git status |thirdparty-windows-amd64 b425ac82 |emcc version |N/A |glibc version |N/A

[!NOTE] You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote. Other reactions and those to comments will not be taken into account.

MARCROCK22 avatar Jun 13 '25 23:06 MARCROCK22

Connected to Huly®: V_0.6-23068

huly-for-github[bot] avatar Jun 13 '25 23:06 huly-for-github[bot]

I ran your code in linux with the same output. By googling I reach this article that shows how to connect using python. There is mentioned you need to create a token and send an identify message to connect. I just guessing.

jorgeluismireles avatar Jun 16 '25 16:06 jorgeluismireles

The authentification has nothing to do with the issue, i tried with a valid token and i also get the same error (Could not read using SSL).

MARCROCK22 avatar Jun 16 '25 16:06 MARCROCK22