Skip to content

ping fails to return on valid connections #10

@agarwal

Description

@agarwal

The complete script is below. Running it with invalid connection parameters immediately returns with an error:

$ ./script.ml -host 127.0.0.1 -port 8097
bad connection

However, using the correct port leads to:

$ ./script.ml -host 127.0.0.1 -port 8098
(* never returns *)

I verified that the normal riak client does ping correctly:

$ riak ping
pong

script.ml

#! /usr/bin/env ocamlscript
Ocaml.ocamlflags := ["-thread"];
Ocaml.packs := ["core"; "async"; "riakc"]
--
open Core.Std
open Async.Std

let main host port : unit Deferred.t =
  let open Deferred.Result.Monad_infix in
  Riakc.Conn.connect ~host ~port
  >>= (fun db -> Riakc.Conn.ping db)
  |> Deferred.map ~f:(function
    | Ok () -> printf "ping succeeded\n"
    | Error `Bad_conn -> printf "bad connection\n"
    | Error `Bad_payload -> printf "bad payload\n"
    | Error _ -> printf "other error\n"
  )

let command =
  Command.async_basic
    ~summary:"test program"
    Command.Spec.(
      empty
      +> flag "host" (required string) ~doc:"HOST host name"
      +> flag "port" (required int) ~doc:"PORT port number"
    )
    (fun host port () -> main host port)

let () = Command.run command

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions