caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Problem with OCaml-websocket + TLS
       [not found] <524115924.2580239.1452522494654.JavaMail.yahoo.ref@mail.yahoo.com>
@ 2016-01-11 14:28 ` Dario Teixeira
  0 siblings, 0 replies; only message in thread
From: Dario Teixeira @ 2016-01-11 14:28 UTC (permalink / raw)
  To: Caml Users

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-01-11 14:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <524115924.2580239.1452522494654.JavaMail.yahoo.ref@mail.yahoo.com>
2016-01-11 14:28 ` [Caml-list] Problem with OCaml-websocket + TLS Dario Teixeira

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).