From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p8BH4aOV022069 for ; Sun, 11 Sep 2011 19:04:36 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AooEADvpbE6GnQCBcGdsb2JhbABBgk2fEoY7FAEMCA4HFAMjgVIBAQQBJ1IFCwtGVweICQS0MoZuBIc+lEaIVw X-IronPort-AV: E=Sophos;i="4.68,364,1312149600"; d="scan'208,217";a="119245134" Received: from shiva.jussieu.fr ([134.157.0.129]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 11 Sep 2011 19:04:35 +0200 Received: from hydrogene.pps.jussieu.fr (hydrogene.pps.jussieu.fr [134.157.168.1]) by shiva.jussieu.fr (8.14.4/jtpda-5.4) with ESMTP id p8BH499p093659 ; Sun, 11 Sep 2011 19:04:22 +0200 (CEST) X-Ids: 165 Received: from duodiscus.localnet (unknown [134.157.168.1]) by hydrogene.pps.jussieu.fr (Postfix) with ESMTP id 691D3C2DF6; Sun, 11 Sep 2011 19:04:07 +0200 (CEST) From: Vincent Balat Organization: PPS =?utf-8?q?Universit=C3=A9_Paris?= Diderot To: ocsigen@sympa.mancoosi.univ-paris-diderot.fr, pierrchp@free.fr Date: Sun, 11 Sep 2011 19:04:36 +0200 User-Agent: KMail/1.13.7 (Linux/2.6.32-5-amd64; KDE/4.6.2; x86_64; ; ) Cc: caml-list@inria.fr References: <1315681085.4e6bb33d6df0e@imp.free.fr> In-Reply-To: <1315681085.4e6bb33d6df0e@imp.free.fr> X-KMail-Markup: true MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="Boundary-01=_koObOAfG5VR/0zX" Content-Transfer-Encoding: 7bit Message-Id: <201109111904.36279.vincent.balat@pps.jussieu.fr> X-Miltered: at jchkmail.jussieu.fr with ID 4E6CEA08.000 by Joe's j-chkmail (http : // j-chkmail dot ensmp dot fr)! X-j-chkmail-Enveloppe: 4E6CEA08.000/134.157.168.1/hydrogene.pps.jussieu.fr/hydrogene.pps.jussieu.fr/ X-Validation-by: vincent.balat@pps.jussieu.fr Subject: [Caml-list] Re: [Ocsigen] Ocamlnet, netclient and lwt_preemptive causing ocsigen segfault --Boundary-01=_koObOAfG5VR/0zX Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hello, No idea about the segmentation fault but if you just want to do an HTTP request, Ocsigen Server (without Ocamlnet's netclient) may be enough for your needs. See module Ocsigen_http_client. http://ocsigen.org/ocsigenserver/2.0-rc1/api/Ocsigen_http_client (I would be interested to understand the problem with netclient, though). Vincent Balat > Hello, > > I have a web application written using lwt and ocsigen that needs to get > data using https. > > In order to do that, I use the Http_client.Convenience module from > Ocamlnet, and use Lwt.detach to perform the call (there probably is a > smater way to do this, I am open to any suggestion). The http call is > performed and the data is displayed, but then the server crashed, > apparently because of a segfault. > > here is the code for a test eliom module that reproduce the problem, > compiled using > > ocamlfind ocamlc -c -thread -package > equeue-ssl,netclient,lwt,lwt.preemptive,ocsigen test_server.ml > > Cheers > > > -Pierre > > > (*************************************) > > open Lwt > open XHTML.M > open Eliom_services > open Eliom_parameters > open Eliom_sessions > open Eliom_predefmod.Xhtml;; > > > > > (* initialising Http_client.Convenience to use https *) > Ssl.init(); > > Http_client.Convenience.configure_pipeline > (fun p -> > let ctx = Ssl.create_context Ssl.TLSv1 Ssl.Client_context in > let tct = Https_client.https_transport_channel_type ctx in > p # configure_transport Http_client.https_cb_id tct > ) > ;; > > > > module H = Http_client.Convenience > > > let test_service = new_service ~path:[""] > ~get_params:unit > () > ;; > > > let test_handler = fun sp () () -> > (* thread that request data from a url *) > Lwt_preemptive.detach (function () -> H.http_get "https://ocsigen.org") () > >>= function s -> > (*page that display the data*) > return ( > html (head (title (pcdata "test")) []) > (body [ > h1 [pcdata "the data are:"]; > p [ pcdata s] > ] > ) > ) > ;; > register test_service test_handler;; --Boundary-01=_koObOAfG5VR/0zX Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit

Hello,


No idea about the segmentation fault but if you just want to do an HTTP request, Ocsigen Server (without Ocamlnet's netclient) may be enough for your needs.

See module Ocsigen_http_client.

http://ocsigen.org/ocsigenserver/2.0-rc1/api/Ocsigen_http_client


(I would be interested to understand the problem with netclient, though).


Vincent Balat




> Hello,

>

> I have a web application written using lwt and ocsigen that needs to get

> data using https.

>

> In order to do that, I use the Http_client.Convenience module from

> Ocamlnet, and use Lwt.detach to perform the call (there probably is a

> smater way to do this, I am open to any suggestion). The http call is

> performed and the data is displayed, but then the server crashed,

> apparently because of a segfault.

>

> here is the code for a test eliom module that reproduce the problem,

> compiled using

>

> ocamlfind ocamlc -c -thread -package

> equeue-ssl,netclient,lwt,lwt.preemptive,ocsigen test_server.ml

>

> Cheers

>

>

> -Pierre

>

>

> (*************************************)

>

> open Lwt

> open XHTML.M

> open Eliom_services

> open Eliom_parameters

> open Eliom_sessions

> open Eliom_predefmod.Xhtml;;

>

>

>

>

> (* initialising Http_client.Convenience to use https *)

> Ssl.init();

>

> Http_client.Convenience.configure_pipeline

> (fun p ->

> let ctx = Ssl.create_context Ssl.TLSv1 Ssl.Client_context in

> let tct = Https_client.https_transport_channel_type ctx in

> p # configure_transport Http_client.https_cb_id tct

> )

> ;;

>

>

>

> module H = Http_client.Convenience

>

>

> let test_service = new_service ~path:[""]

> ~get_params:unit

> ()

> ;;

>

>

> let test_handler = fun sp () () ->

> (* thread that request data from a url *)

> Lwt_preemptive.detach (function () -> H.http_get "https://ocsigen.org") ()

> >>= function s ->

> (*page that display the data*)

> return (

> html (head (title (pcdata "test")) [])

> (body [

> h1 [pcdata "the data are:"];

> p [ pcdata s]

> ]

> )

> )

> ;;

> register test_service test_handler;;


--Boundary-01=_koObOAfG5VR/0zX--