title: "Resource temporarily unavailable" when trying to connect to https websocket with ws-rs (mio)
body: <p>I am trying to establish a secure connection using Rust <a href="https://github.com/housleyjk/ws-rs" rel="nofollow noreferrer"><code>ws-rs</code></a> (based on mio).</p>
  
  <p>The part of the code that I think is relevant:</p>
  
  <pre><code>impl ws::Handler for Client {
      fn on_message(&amp;mut self, msg: ws::Message) -&gt; ws::Result&lt;()&gt; {
          println!("msg = {}", msg);
          self.out.close(ws::CloseCode::Normal)
      }
  
      fn upgrade_ssl_client(
          &amp;mut self,
          sock: TcpStream,
          _: &amp;url::Url,
      ) -&gt; ws::Result&lt;SslStream&lt;TcpStream&gt;&gt; {
          let mut builder = SslConnector::builder(SslMethod::tls()).map_err(|e| {
              ws::Error::new(
                  ws::ErrorKind::Internal,
                  format!("Failed to upgrade client to SSL: {}", e),
              )
          })?;
          builder.set_verify(SslVerifyMode::empty());
  
          let connector = builder.build()
              .configure()
              .unwrap()
              .use_server_name_indication(false)
              .verify_hostname(false)
              .connect("localhost:12321", sock)
              .unwrap();
  
          Ok(connector)
      }
  }
  </code></pre>
  
  <p>A complete example is at <a href="https://github.com/mverleg/mwe_ws_rs_connectivity_issues/blob/master/rs_ws_ssl_server_client.rs" rel="nofollow noreferrer">Github</a>, it's ~150 lines which is as small as I could get it.</p>
  
  <p>I get this error:</p>
  
  <pre><code>thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value:
  WouldBlock(MidHandshakeSslStream {
      stream: SslStream {
          stream: TcpStream { addr: V4(127.0.0.1:52164), peer: V4(127.0.0.1:12321), fd: 12 },
          ssl: Ssl { state: "SSLv2/v3 read server hello A", verify_result: X509VerifyResult { code: 0, error: "ok" } }
      }, error: Error {
          code: ErrorCode(2),
          cause: Some(Io(Os {
              code: 11,
              kind: WouldBlock,
              message: "Resource temporarily unavailable"
          }))
      }
  })
  </code></pre>
  
  <p>I don't really know what that means...</p>
  
  <p>(I also created a ws-rs Github <a href="https://github.com/housleyjk/ws-rs/issues/247" rel="nofollow noreferrer">issue</a> last month as I thought it might be a problem with the lib or the example)</p>