* [Caml-list] Ocamlnet, netclient and lwt_preemptive causing ocsigen segfault
@ 2011-09-10 18:58 pierrchp
2011-09-11 8:27 ` Gerd Stolpmann
2011-09-11 17:04 ` [Caml-list] Re: [Ocsigen] " Vincent Balat
0 siblings, 2 replies; 3+ messages in thread
From: pierrchp @ 2011-09-10 18:58 UTC (permalink / raw)
To: caml-list, ocsigen
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;;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Ocamlnet, netclient and lwt_preemptive causing ocsigen segfault
2011-09-10 18:58 [Caml-list] Ocamlnet, netclient and lwt_preemptive causing ocsigen segfault pierrchp
@ 2011-09-11 8:27 ` Gerd Stolpmann
2011-09-11 17:04 ` [Caml-list] Re: [Ocsigen] " Vincent Balat
1 sibling, 0 replies; 3+ messages in thread
From: Gerd Stolpmann @ 2011-09-11 8:27 UTC (permalink / raw)
To: pierrchp; +Cc: caml-list, ocsigen
Am Samstag, den 10.09.2011, 20:58 +0200 schrieb pierrchp@free.fr:
> 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.
Run the server under gdb, and get a backtrace after the crash.
> 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
Unfortunately, it is still impossible to run Ocamlnet protocol
interpreters on top of Lwt's event dispatcher. I really wished we had
here a better way of combining both systems.
Gerd
>
> 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;;
>
--
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de
Creator of GODI and camlcity.org.
Contact details: http://www.camlcity.org/contact.html
Company homepage: http://www.gerd-stolpmann.de
*** Searching for new projects! Need consulting for system
*** programming in Ocaml? Gerd Stolpmann can help you.
------------------------------------------------------------
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Caml-list] Re: [Ocsigen] Ocamlnet, netclient and lwt_preemptive causing ocsigen segfault
2011-09-10 18:58 [Caml-list] Ocamlnet, netclient and lwt_preemptive causing ocsigen segfault pierrchp
2011-09-11 8:27 ` Gerd Stolpmann
@ 2011-09-11 17:04 ` Vincent Balat
1 sibling, 0 replies; 3+ messages in thread
From: Vincent Balat @ 2011-09-11 17:04 UTC (permalink / raw)
To: ocsigen, pierrchp; +Cc: caml-list
[-- Attachment #1: Type: text/plain, Size: 2158 bytes --]
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;;
[-- Attachment #2: Type: text/html, Size: 14955 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-09-11 17:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-10 18:58 [Caml-list] Ocamlnet, netclient and lwt_preemptive causing ocsigen segfault pierrchp
2011-09-11 8:27 ` Gerd Stolpmann
2011-09-11 17:04 ` [Caml-list] Re: [Ocsigen] " Vincent Balat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox