vbmithr / ocaml-websocket

Websocket library for OCaml
ISC License
163 stars 44 forks source link

Fixed writer error #20

Closed SGrondin closed 9 years ago

SGrondin commented 9 years ago

Alright,

I'm still kinda new to OCaml, but I hope I'll be able to save you some time. I wrote this little program to test your library with Cohttp 0.12.0 and my fix to your version 0.9.

open Core.Std
open Lwt
open Websocket

try_lwt (
    Tls_lwt.rng_init ()
    >>= fun () ->
        let () = print_endline "abc" in
        return ()
    >>= fun () ->
        let () = print_endline "def" in
        Websocket.open_connection (Uri.of_string "http://127.0.0.1:4000")
    >>= fun (stream, push) ->
        let () = print_endline "ghi" in
        return ()
) with
| End_of_file -> return (print_endline "eof!!")
| x -> Exn.to_string x |> fun s -> s^"!!!!!" |> print_endline |> return

When connecting to a simple socket.io server, it crashes right away with End_of_file and never prints "ghi" (yes, I'm using blocking print statements intentionally for this test). Maybe there's a bug in my test, but if there isn't, then I hope this will help you narrow it down!

Thanks!