Re: Strange error with HTTP_Client

Pierre-Alexandre Voye <[email protected]> Fri, 6 Apr 2012 18:01:16 +0200
Newsgroups gmane.comp.lang.ocaml.lib.net.devel
Message-ID <CANnJ5GfoYJy0Jutqhea80ViGZNSvvZ2fsPg6t4XaQihm2qyRRw@mail.gmail.com>
I found a fix :
I seted parallelizer with
 Netplex_mp.mp ~keep_fd_open:true ()

It was a lot intuitive (as the way I found it in the doc) and i don't
understand completely why it works now. Seems that Netplex closes
descriptor too early.

Le 6 avril 2012 15:51, Pierre-Alexandre Voye <[email protected]> a écrit
:

> Hi,
>
> my app failed systematically when it try to connect to my Alfresco server.
>
>
> Context :
> my program is a cgi http server which make himself certain http call.
> It is runned in a multiprocess manner, and it is interesting to note that
> my problem disappear if you set to multi-thread instead of multiprocess.
>
> In the main I have :
>
>  let nethttpd_factory =  Nethttpd_plex.nethttpd_factory
> ~handlers:handlers () in
>   Netplex_main.startup  parallelizer
>     Netplex_log.logger_factories   (* allow all built-in logging styles *)
>     Netplex_workload.workload_manager_factories (* ... all ways of
> workload management *)
>     [ nethttpd_factory ]           (* make this nethttpd available *)
>     cmdline_cfg
> ;;
>
>
>
> Now, the error
>
>
> Apparently (according to stack trace), it fails on
> Http_client.Convenience.http_get
>
> It doesn't throw an error, but (captured in the error of the CGI which is
> called) :
> Unix.Unix_error(EINVAL, "read (result invalid)", "")
>
> Here's the code where it failed :
>
> let requete_get url          =    Utils.info ("GET "^url) ; try
>
> Http_client.Convenience.http_get    url
> <---------------------------------------
>                                                         with
>
> Http_client.Http_error (nerr,msg) ->
>
> Utils.log2  ("requete_get : "^(string_of_int nerr))
> (Printexc.get_backtrace ()) msg; ""
>
> The associated log with "-debug Http_client" parameter is show in [1]
>
>
> More suprising, I tried to modify requete_get by
>
> let requete_get url          =    Utils.info ("GET "^url) ;
>                                   Utils.execute_command ("curl -s
> '"^url^"'")   (* execute_command : string -> string       execute an unix
> command and return  the result in a string*)
>
> It failed too, but works sometimes and the logs give :
>
> [Fri Apr  6 15:34:35 2012] [debug] [52085:0] Netlog: WARNING track_fd:
> descriptor already tracked as 4(Netsys_posix - create_event)
> [Fri Apr  6 15:34:35 2012] [debug] [52085:0] Netlog: track_fd: tracking
> descriptor 4(Netsys_posix - create_event)
> [Fri Apr  6 15:34:35 2012] [nethttpd] [crit] run: Exception
> Unix.Unix_error(EINVAL, "read (result invalid)", "")
>
> and
> Sys_error("Bad file descriptor");;Raised by primitive operation at file "
> pervasives.ml", line 325, characters 12-32
> Called from file "Utils.ml", line 97, characters 24-41
> <---------------------- in the Utils.execute_command function
>
>
> In advance, thank you for your help
>
> Regards,
>
> Pierre-Alexandre
>
>
> [1] Logs of the first version of function requete_get which use Http_client
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: FD 11 - HTTP
> connection: Got Call 2121!
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: FD 11 - HTTP
> connection: pipelining=true persistency=false close_connection=false->false
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: Call 2121 -
> postprocessing
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: FD 11 - HTTP
> connection: Shutdown!
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: FD 11 - HTTP
> connection: Closing socket!
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: HTTP connection:
> checking remaining pipeline requests
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: HTTP connection:
> creating direct connection to alfrescodev:8080
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: FD 11 - HTTP
> direct connection to alfrescodev:8080: Connected!
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: HTTP Connection:
> adding call 2353
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: Call 2353:
> initialize transmitter
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: FD 11 - Call
> 2353 - HTTP request: GET
> /alfresco/service/docasu/ui/folder/docs?nodeId=8eb7be3d-0790-493d-a173-0140f7b91df1&alf_ticket=TICKET_9fecb90892eb5703a31ff18793709955bbf550d9
> HTTP/1.1
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: FD 11 - HTTP
> connection: Got Call 2353!
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: FD 11 - HTTP
> connection: pipelining=true persistency=false close_connection=false->false
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: Call 2353 -
> postprocessing
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: FD 11 - HTTP
> connection: Shutdown!
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: FD 11 - HTTP
> connection: Closing socket!
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: HTTP connection:
> checking remaining pipeline requests
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: FD 11 - Shutdown
> error: Unix.Unix_error(EBADF, "shutdown", "")
> [Fri Apr  6 15:13:07 2012] [nethttpd] [crit] Unix.shutdown (fd 11):
> Exception Unix.Unix_error(EBADF, "shutdown", "")
> [Fri Apr  6 15:13:07 2012] [nethttpd] [crit] Unix.close (fd 11): Exception
> Unix.Unix_error(EBADF, "close", "")
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: HTTP connection:
> creating direct connection to alfrescodev:8080
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: FD 4 - HTTP
> direct connection to alfrescodev:8080: Connected!
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Netlog: WARNING track_fd:
> descriptor already tracked as 4(Netsys_posix - create_event)
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Netlog: track_fd: tracking
> descriptor 4(Http_client - HTTP direct connection to alfrescodev:8080)
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: HTTP Connection:
> adding call 2614
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: Call 2614:
> initialize transmitter
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: FD 4 - Call 2614
> - HTTP request: GET
> /alfresco/service/docasu/ui/folder/docs?nodeId=f82b2906-9f56-463b-8ff8-f2e0545ed2f8&alf_ticket=TICKET_9fecb90892eb5703a31ff18793709955bbf550d9
> HTTP/1.1
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: HTTP connection:
> reset
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: FD 4 - HTTP
> connection: Shutdown!
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: FD 4 - HTTP
> connection: Closing socket!
> [Fri Apr  6 15:13:07 2012] [debug] [49549:0] Http_client: Call 2614 -
> error Http_client.No_reply
>
>
>
>
>
> --
> ---------------------
> https://twitter.com/#!/ontologiae/
> http://linuxfr.org/users/montaigne
>
>


-- 
---------------------
https://twitter.com/#!/ontologiae/
http://linuxfr.org/users/montaigne

------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2

_______________________________________________
Ocamlnet-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ocamlnet-devel