OK, took my usual approach when stuck, which is to try and turn it into a different problem! Decided to stop trying to use handle* directly, but rather explicitly start an nREPL server on a socket, and relay those messages over websocket. Seems to work fine :-)
Thanks, Jony On Thursday, 27 February 2014 17:58:27 UTC, Jony Hudson wrote: > > Hi Folks, > > I'm stuck and would like a bit of help. This is following on from a > question I posted to clojure.tools, but I've reduced the problem to its > essence, and figure it might get a few more eyes on it here. My apologies > to anyone who has to suffer reading about it twice :-) > > My actual problem is that I'm unable to get a Websocket transport for > gorilla-repl running. But I think I've boiled down the problem to something > that doesn't involve websockets. I'm trying to handle messages with nREPL. > If I run the following in the REPL to make an nREPL handler: > > (require '[clojure.tools.nrepl.transport :as transport]) > (require '[clojure.tools.nrepl.server :as nrepl-server]) > > (def handler (nrepl-server/default-handler)) > > (def trans (transport/fn-transport nil println)) > > (nrepl-server/handle* {:op "clone"} handler trans) > > Then everything goes as I would hope. The nREPL server replies with a > new-session message, which is printed to the console by the dopey transport > I've provided. If I then lift the new session ID (copy and paste) and send > an evaluation message to the nREPL handler > > (nrepl-server/handle* {:op "eval" :code "(+ 1 5)" :session > "2c8b0464-7e09-4c94-81d7-c4e0c7d1314f"} handler trans) > > It works as I'd expect, replying with the value and a 'done' status > message. > > {status #{:done}, session 2c8b0464-7e09-4c94-81d7-c4e0c7d1314f} > {ns user, value 6, session 2c8b0464-7e09-4c94-81d7-c4e0c7d1314f} > > The problem comes if I try and execute the same command again, which > should I would have thought should give the same answer, but instead I get > an extremely long stack trace, a snippet of which is below. > > Exception in thread "nREPL-worker-0" java.lang.StackOverflowError > at clojure.lang.RestFn.applyTo(RestFn.java:130) > at clojure.core$apply.invoke(core.clj:617) > at clojure.core$prn.doInvoke(core.clj:3367) > at clojure.lang.RestFn.applyTo(RestFn.java:137) > at clojure.core$apply.invoke(core.clj:617) > at clojure.core$println.doInvoke(core.clj:3387) > at clojure.lang.RestFn.invoke(RestFn.java:408) > at clojure.tools.nrepl.transport.FnTransport.send(transport.clj:28) > at > clojure.tools.nrepl.middleware.pr_values$pr_values$fn$reify__2353.send(pr_values.clj:23) > at > clojure.tools.nrepl.middleware.session$session_out$fn__2437.invoke(session.clj:51) > at > clojure.tools.nrepl.middleware.session.proxy$java.io.Writer$0.flush(Unknown > Source) > at > clojure.tools.nrepl.middleware.session$session_out$fn__2444.doInvoke(session.clj:44) > at clojure.lang.RestFn.invoke(RestFn.java:460) > at > clojure.tools.nrepl.middleware.session.proxy$java.io.Writer$0.write(Unknown > Source) > at java.io.PrintWriter.write(PrintWriter.java:456) > at java.io.PrintWriter.write(PrintWriter.java:473) > at clojure.core$fn__5420.invoke(core_print.clj:187) > at clojure.lang.MultiFn.invoke(MultiFn.java:231) > at clojure.core$pr_on.invoke(core.clj:3322) > at clojure.core$print_map$fn__5428.invoke(core_print.clj:200) > at clojure.core$print_sequential.invoke(core_print.clj:58) > at clojure.core$print_map.invoke(core_print.clj:203) > at clojure.core$fn__5431.invoke(core_print.clj:207) > at clojure.lang.MultiFn.invoke(MultiFn.java:231) > at clojure.core$pr_on.invoke(core.clj:3322) > at clojure.core$pr.invoke(core.clj:3334) > at clojure.lang.AFn.applyToHelper(AFn.java:161) > at clojure.lang.RestFn.applyTo(RestFn.java:132) > at clojure.core$apply.invoke(core.clj:617) > at clojure.core$prn.doInvoke(core.clj:3367) > at clojure.lang.RestFn.applyTo(RestFn.java:137) > at clojure.core$apply.invoke(core.clj:617) > at clojure.core$println.doInvoke(core.clj:3387) > at clojure.lang.RestFn.invoke(RestFn.java:408) > at clojure.tools.nrepl.transport.FnTransport.send(transport.clj:28) > at > clojure.tools.nrepl.middleware.pr_values$pr_values$fn$reify__2353.send(pr_values.clj:23) > at > clojure.tools.nrepl.middleware.session$session_out$fn__2437.invoke(session.clj:51) > at > clojure.tools.nrepl.middleware.session.proxy$java.io.Writer$0.flush(Unknown > Source) > at > clojure.tools.nrepl.middleware.session$session_out$fn__2444.doInvoke(session.clj:44) > [snip] > > Somehow, drawbridge gets this to work, even though as far as I can tell > I'm doing the same thing. I can't figure out what's going on. Help! > > Thanks, > > > Jony > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.