adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
531 stars 128 forks source link

Websocket with wss address never calls do_ssl_connect #350

Closed CoderNate closed 10 months ago

CoderNate commented 1 year ago

I think https://github.com/adamdruppe/arsd/commit/0d61b0ef04813d62fe2adadbb93c8cbee2f85d35 and/or the commit before it from the same day (https://github.com/adamdruppe/arsd/commit/50592d35f34ac452ce182668dc3f4b07c32913ff) caused the problem I'm seeing where connecting to a wss address fails. The changes modified connect so that do_ssl_connect would only be called if blocking is true. The WebSocket class creates and uses its own private SslClientSocket and the socket seems to default to blocking being false. Here's my code:

    auto cfg = WebSocket.Config();
    cfg.verifyPeer = false;
    auto ws = new WebSocket(Uri("wss://localhost:8181"), cfg);
    ws.connect();

In arsd 10.9.6 I ran through with a debugger and verified that connect skips over the do_ssl_connect call. But if I edit the code and add socket.blocking = true at the end of the Websocket constructor then the call to connect works and I can then send and receive messages.

I verified that arsd 10.8.4 (the last tagged release before the commit I linked) was able to connect over wss and send and receive a message.

adamdruppe commented 1 year ago

oooh that's probably true. it is a fairly straightforward fix, let me get together a test thing and do a fix. in the middle of something else right now but i'll be back to it in about an hour.

adamdruppe commented 1 year ago

neither of those commits changed the websocket though. that's weird. blocking is true by default.

adamdruppe commented 1 year ago

https://github.com/dlang/phobos/pull/8630

CoderNate commented 1 year ago

Thanks for fixing this!

adamdruppe commented 10 months ago

I'm actually not 100% sure I fixed this correctly in my code, but.... your comment and my vague recollection is that it is right now, so gonna close this. Reopen if i messed it up though.