Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Dario Teixeira <darioteixeira@yahoo.com>
To: Caml Users <caml-list@inria.fr>
Subject: [Caml-list] Problem with OCaml-websocket + TLS
Date: Mon, 11 Jan 2016 14:28:14 +0000 (UTC)	[thread overview]
Message-ID: <524115924.2580239.1452522494654.JavaMail.yahoo@mail.yahoo.com> (raw)
In-Reply-To: <524115924.2580239.1452522494654.JavaMail.yahoo.ref@mail.yahoo.com>

Hi,

Consider the code below, which implements a simple Websocket server based on 
the OCaml-websocket library.  Depending on whether Config.websocket_protocol
is `TCP or `TLS, the server will use either plain TCP or TLS for transport,
respectively.  My problem is that while the TCP backend works fine, the
TLS one doesn't.  To be more precise, the client (a web browser) seems to
establish a connection, but as soon as it attempts to send any data through 
it, an unexpected close happens (error code 1006).

let server () =
  let handler id req recv send =
    (* handler code goes here *)
  in begin match !Config.websocket_protocol with
    | `TCP ->
      let ctx = Conduit_lwt_unix.default_ctx in
      let endp = `TCP (Ipaddr.(V4 V4.any), !Config.websocket_port) in
      Lwt.return (ctx, endp)
    | `TLS ->
      let tls_server_key = `TLS (`Crt_file_path !Config.websocket_certfile, `Key_file_path !Config.websocket_keyfile, `No_password) in
                 Conduit_lwt_unix.init ~tls_server_key () >>= fun ctx ->
      let endp = `TLS ("playceemi.com", `TCP (Ipaddr.(V4 V4.any), !Config.websocket_port)) in
      Lwt.return (ctx, endp)
  end >>= fun (ctx, endp) ->
  Conduit_lwt_unix.endp_to_server ~ctx endp >>= fun server ->
  Websocket_lwt.establish_standard_server ~ctx ~mode:server handler


I've also tried this with CONDUIT_TLS set to "native", but the problem persists.
Finally, note that the server above is run from within an Ocsigen server, though
I don't think that should be a problem (different ports are used).

Any idea on what the problem could be?
(And thanks in advance!)

Best regards,
Dario Teixeira

           reply	other threads:[~2016-01-11 14:28 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <524115924.2580239.1452522494654.JavaMail.yahoo.ref@mail.yahoo.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=524115924.2580239.1452522494654.JavaMail.yahoo@mail.yahoo.com \
    --to=darioteixeira@yahoo.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox