Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

A) I'm having a problem where Cider can't cider-connect-clj (or cider-connect-cljs) to an nREPL server I launch in my application code. Cursive also doesn't work. It must be a simple configuration or middleware that needs to be included. But I've been looking at this code too long. What I missing?

I have a Clojure file that looks something like this.

(ns some.namespace
  (:require nrepl.server
            cider.nrepl))

(nrepl.server/start-server
  :port 1234
  :handler
  (fn [_]
    (nrepl.server/default-handler cider.nrepl/cider-middleware)))

nrepl.server/start-server starts ok. From Emacs I can connect by calling cider-connect-clj (or cider-connect-cljs). But then the REPL fails to initialize on a "sync" request.

i. Emacs console

[nREPL] Direct connection to localhost:6776 established
nrepl-send-sync-request: Sync nREPL request timed out (op clone id 1 time-stamp 2021-02-04 23:13:46.789763000)

ii. nREPL console

[WARNING] No nREPL middleware descriptor in metadata of null, see nrepl.middleware/set-descriptor!

B) I'm actually running Figwheel-Main and connecting an nREPL, for a Clojurescript connection. All within my Clojure app.

;; λ clj -A:dev -m some.namespace
:dev
{:extra-paths ["dev" "test"]
 :extra-deps {org.clojure/clojure       {:mvn/version "1.10.0"}
              org.clojure/clojurescript {:mvn/version "1.10.520"}
              com.bhauman/figwheel-main {:mvn/version "0.2.0"}
              nrepl/nrepl               {:mvn/version "0.8.3"}
              cider/cider-nrepl         {:mvn/version "0.25.8"}
              cider/piggieback          {:mvn/version "0.4.2"}}}

I don't think the Figwheel portion is affecting cider's attempts to connect. But I'm including it just for context.

(defn -main [& args]

  ;; Start Figwheel Server
  (figwheel.main.api/start
    {:mode :serve} "dev")


  ;; Start nREPL
  (def server (nrepl.server/start-server
                :port 1234
                :handler
                (fn [_]
                  (nrepl.server/default-handler cider.nrepl/cider-middleware))))


  ;; Start Figwheel REPL
  (fig/cljs-repl "dev"))
question from:https://stackoverflow.com/questions/66057626/cider-connect-clj-cannot-connect-to-nrepl-server-start-server

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
844 views
Welcome To Ask or Share your Answers For Others

1 Answer

It seems that you're starting the nREPL on port 1234, but then Emacs is trying to connect to port 6776. Could that be the reason?

When you run cider-connect-clj?you can select the port you want connect to. Try changing the default port to 1234 and see if that helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...