drawbridge icon indicating copy to clipboard operation
drawbridge copied to clipboard

Fails with "java.net.Socket cannot be cast to class java.lang.String"

Open holyjak opened this issue 6 years ago • 9 comments

I want to connect to a remote nREPL server but the invocation fails:

deps.edn:

{:aliases {:repl {:extra-deps {nrepl/nrepl {:mvn/version "0.6.0"} 
                                              nrepl/drawbridge {:mvn/version "0.2.1"}}
           :main-opts  ["-m" "nrepl.cmdline" "--connect" "--transport" 
                               "drawbridge.client/ring-client-transport" 
                               "--port" "55555" "--host"]}}}

command:

clojure -Arepl 10.199.227.33

output:

Execution error (ClassCastException) at clj-http.client/parse-url (client.clj:175). class java.net.Socket cannot be cast to class java.lang.String (java.net.Socket and java.lang.String are in module java.base of loader 'bootstrap')

See the full output from clojure in this gist: https://gist.github.com/holyjak/7a644ef57bc17807ac18d22d820bbda7

Environment

  • Amazon Linux 2 or OSX
  • JVM java-11-amazon-corretto.x86_64 or java-1.8.0-openjdk

It is quite likely I do something wrong but I have no idea what :(

It works with lein

Using leiningen 2.9 and project.clj:

(defproject repl-client-drawbridge "0.1.0-SNAPSHOT"
  :plugins [[nrepl/drawbridge "0.2.1"]])

this works:

$ lein repl :connect http://10.199.227.33:55555
Connecting to nREPL at http://10.199.227.33:55555
REPL-y 0.4.3, nREPL 0.6.0
Clojure 1.10.1
OpenJDK 64-Bit Server VM 11.0.1+13
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=>

holyjak avatar Dec 11 '19 12:12 holyjak

Looking at the stacktrace, it seems to me some conversion is missing. Probably Lein does it somewhere, but we don't do it in the built-in CLI.

bbatsov avatar Dec 12 '19 08:12 bbatsov

The problem persists:

$ clj -Sdeps '{:deps {nrepl/drawbridge {:mvn/version "0.2.1"}}}' \
    -m nrepl.cmdline --transport drawbridge.client/ring-client-transport \
    --connect --host localhost --port 5050
WARNING: When invoking clojure.main, use -M
nREPL 0.8.3
Clojure 1.10.1
OpenJDK 64-Bit Server VM 11.0.9.1+1-Ubuntu-0ubuntu1.20.10
Interrupt: Control+C
Exit:      Control+D or (exit) or (quit)
Execution error (ClassCastException) at clj-http.client/parse-url (client.clj:170).
class java.net.Socket cannot be cast to class java.lang.String (java.net.Socket and java.lang.String are in module java.base of loader 'bootstrap')

Full report at:
/tmp/clojure-7424303235548335896.edn

And the clj-http.client/parse-url line 170 is here https://github.com/dakrone/clj-http/blob/24d195596b6f1ace411f1a3690526338fca9e331/src/clj_http/client.clj#L170


Dear Santa 🎅!

The 2020 wasn't that much of a fun. We'll call it quits if you help us make this bug 🐞 go disappear.

PS: Just in case... we know where ❄️️​ you live! #globalwarming

Bost avatar Dec 21 '20 02:12 Bost

Interestingly enough, it doesn't work properly with the latest leiningen.

Old leiningen 2.9.0:

$ lein version
Leiningen 2.9.0 on Java 11.0.9.1 OpenJDK 64-Bit Server VM
$ lein repl :connect http://localhost:5555/repl
Connecting to nREPL at http://localhost:5555/repl
REPL-y 0.4.3, nREPL 0.6.0
Clojure 1.10.1
OpenJDK 64-Bit Server VM 11.0.9.1+1-Ubuntu-0ubuntu1.20.10
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=>

Current 2.9.5:

$ lein version
Leiningen 2.9.5 on Java 11.0.9.1 OpenJDK 64-Bit Server VM
$ lein repl :connect http://localhost:5555/repl
Connecting to nREPL at http://localhost:5555/repl

and it doesn't go past this point.

Bost avatar Dec 22 '20 02:12 Bost

Don't have much time for Drawbridge these days, so any help with debugging the problem would be appreciated. I'm assuming the problem with the latest lein might be related to the use of a newer version of nREPL, although I can't think of any particular change that might break this.

bbatsov avatar Dec 22 '20 06:12 bbatsov

Does this work with Lein 2.9.4?

bbatsov avatar Dec 22 '20 06:12 bbatsov

It works with 2.9.3 and does NOT work with 2.9.4. Here's a little script to test it with different leiningens:

#!/usr/bin/env bash

versions=(
    '2.9.3'
    '2.9.4'
    # '2.9.5'
)

mkdir ~/bin/

for ver in "${versions[@]}"; do
    wget -O ~/bin/lein-$ver https://raw.githubusercontent.com/technomancy/leiningen/$ver/bin/lein
    chmod +x ~/bin/lein-$ver
    lein-$ver repl :connect http://localhost:5555/repl
    # press Ctrl-C for the next iteration
done

Sorry that I didn't bisect it straight away it was past 3 a.m.

Bost avatar Dec 22 '20 12:12 Bost

Got it. Then it's likely something to do with nREPL 0.7. //cc @shen-tian

bbatsov avatar Dec 22 '20 15:12 bbatsov

@Bost Did you find a solution to this? I'm seeing it with lein 2.9.5. The client is flooding GET requests, but the repl never fully connects.

I've verified 2.9.3 works (thanks so much for finding that).

jeaye avatar Dec 18 '21 08:12 jeaye

Perhaps overriding the default nREPL version will fix the problem?

bbatsov avatar Dec 18 '21 11:12 bbatsov