Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LEIN_FAST_TRAMPOLINE causes intermittent java.net.ConnectException: Connection refused on Mac #1562

Closed
oinksoft opened this issue Jun 16, 2014 · 7 comments · Fixed by #1691
Closed
Labels
Milestone

Comments

@oinksoft
Copy link

With LEIN_FAST_TRAMPOLINE set, a subsequent invocation of lein repl fails, hanging on "Connection refused." Running a lein clean allows for a single successful lein repl invocation. Note no use of trampoline.

Using Clojure 1.6.1, Java 1.8.0_05, Leiningen 2.4.0, Mac OS 10.9.3.

>> lein repl
Exception in thread "main" java.net.ConnectException: Connection refused, compiling:(/foo/target/87dfbe88573d47a5c03ff7fb171fb19207f5bcee-init.clj:1:1)
    at clojure.lang.Compiler.load(Compiler.java:7142)
    at clojure.lang.Compiler.loadFile(Compiler.java:7086)
    at clojure.main$load_script.invoke(main.clj:274)
    at clojure.main$init_opt.invoke(main.clj:279)
    at clojure.main$initialize.invoke(main.clj:307)
    at clojure.main$null_opt.invoke(main.clj:342)
    at clojure.main$main.doInvoke(main.clj:420)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:383)
    at clojure.lang.AFn.applyToHelper(AFn.java:156)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.main.main(main.java:37)
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at java.net.Socket.<init>(Socket.java:434)
    at java.net.Socket.<init>(Socket.java:211)
    at clojure.tools.nrepl$connect.doInvoke(nrepl.clj:184)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.tools.nrepl.ack$send_ack.invoke(ack.clj:47)
    at clojure.tools.nrepl.server$start_server.doInvoke(server.clj:146)
    at clojure.lang.RestFn.invoke(RestFn.java:619)
    at user$eval7745.invoke(87dfbe88573d47a5c03ff7fb171fb19207f5bcee-init.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6703)
    at clojure.lang.Compiler.eval(Compiler.java:6693)
    at clojure.lang.Compiler.load(Compiler.java:7130)
    ... 11 more
REPL server launch timed out.
>> lein clean
>> lein repl
nREPL server started on port 49447 on host 127.0.0.1 - nrepl://127.0.0.1:49447
REPL-y 0.3.1
Clojure 1.6.0
    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=> Bye for now!
>> lein repl
Exception in thread "main" java.net.ConnectException: Connection refused, compiling:(/foo/target/87dfbe88573d47a5c03ff7fb171fb19207f5bcee-init.clj:1:1)
    at clojure.lang.Compiler.load(Compiler.java:7142)
    at clojure.lang.Compiler.loadFile(Compiler.java:7086)
    at clojure.main$load_script.invoke(main.clj:274)
    at clojure.main$init_opt.invoke(main.clj:279)
    at clojure.main$initialize.invoke(main.clj:307)
    at clojure.main$null_opt.invoke(main.clj:342)
    at clojure.main$main.doInvoke(main.clj:420)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:383)
    at clojure.lang.AFn.applyToHelper(AFn.java:156)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.main.main(main.java:37)
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at java.net.Socket.<init>(Socket.java:434)
    at java.net.Socket.<init>(Socket.java:211)
    at clojure.tools.nrepl$connect.doInvoke(nrepl.clj:184)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.tools.nrepl.ack$send_ack.invoke(ack.clj:47)
    at clojure.tools.nrepl.server$start_server.doInvoke(server.clj:146)
    at clojure.lang.RestFn.invoke(RestFn.java:619)
    at user$eval7745.invoke(87dfbe88573d47a5c03ff7fb171fb19207f5bcee-init.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6703)
    at clojure.lang.Compiler.eval(Compiler.java:6693)
    at clojure.lang.Compiler.load(Compiler.java:7130)
    ... 11 more
>> unset LEIN_FAST_TRAMPOLINE
>> lein clean
>> lein repl
nREPL server started on port 49454 on host 127.0.0.1 - nrepl://127.0.0.1:49454
REPL-y 0.3.1
Clojure 1.6.0
    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=> Bye for now!
>> lein repl
nREPL server started on port 49458 on host 127.0.0.1 - nrepl://127.0.0.1:49458
REPL-y 0.3.1
Clojure 1.6.0
    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=> Bye for now!
@oinksoft
Copy link
Author

*Clojure 1.6.0, no 1.6.1 yet!

@oinksoft
Copy link
Author

This morning I am running into this issue with or without LEIN_FAST_TRAMPOLINE. Note that I've already tried fixes found in other reports of this bug (disabling firewall, etc.) to no avail.

This is not an issue when using 2.3.4 on the same machine.

@technomancy
Copy link
Owner

Can you run lein repl :headless :port 9999 and connect with telnet?

@oinksoft
Copy link
Author

Sure, note that with a test user in a new test project I confirmed that this issue reliably appears in 2.4.2 and not in 2.3.4, and that it only occurs with LEIN_FAST_TRAMPOLINE set. I should've double-checked that it was not set when this begin failing again earlier (it was).

I am able to repeatedly start an nREPL with lein repl :headless :port 9999, and also to connect to it with telnet. telnet fails to reach the host over IPv6 and then succeeds over IPv4.

@technomancy technomancy added this to the 2.4.3 milestone Jun 16, 2014
@technomancy
Copy link
Owner

3addf52 is the only change in the repl task since 2.3.4 apart from docstrings and a reply bump. Maybe @trptcolin has an idea of what could have caused this?

@trptcolin
Copy link
Collaborator

Hmm, I haven't used LEIN_FAST_TRAMPOLINE, but hopefully this data point helps? In 2.4.2, running lein repl leaves a file SOME_SHA_LOOKING_THING-init.clj under target/, but that doesn't happen in 2.3.4: https://gist.github.com/trptcolin/64286df9771aba8f8857

The thing that made me wonder about this file (other than it being implicated in the stacktrace) was that it has an ack-port explicitly specified in it. I don't recall all the details around the ack port, but it looks like starting the nrepl server resets the port.

Notable: lein trampoline repl appears to work (-ish: it appears to need a (shutdown-agents) both here and in past lein versions, maybe since 2.3.4). Opening a separate issue for that.

@technomancy
Copy link
Owner

I see the problem; it's a bug in the code that writes out the eval-in-project file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants