-
-
Notifications
You must be signed in to change notification settings - Fork 219
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
calva/vscode wrongly assumes nrepl started at ::1 (ipv6) #2310
Comments
workaround (force ipv4) diff --git a/src/nrepl/index.ts b/src/nrepl/index.ts
index 8d685fea..86c253d3 100644
--- a/src/nrepl/index.ts
+++ b/src/nrepl/index.ts
@@ -130,7 +130,7 @@ export class NReplClient {
*/
static create(opts: { host: string; port: number; onError: (e) => void }) {
return new Promise<NReplClient>((resolve, reject) => {
- const socket = net.createConnection(opts, () => {
+ const socket = net.createConnection({ ...opts, family: 4 }, () => {
const nsId = client.nextId;
const cloneId = client.nextId;
const describeId = client.nextId; |
Maybe what changed is some default socket creation options? But how would those change... Very strange. |
since
(with the explicit default set here) I think this is simply under-specified. If calva wants to use nrepl defaults - |
Do you mean that if we connect to the nrepl server on port 127.0.0.1, we would avoid the ambiguity? A problem is that the nrepl server reports that it starts the nrepl on localhost, and this is what Calva uses to figure out what address to connect to. The nrepl code for this is here, and I can't quite follow: https://github.com/nrepl/nrepl/blob/5839006c5f522fd5e6cf2adbcc5b59e4bd0677dd/src/clojure/nrepl/cmdline.clj#L446 Maybe you should report this on nrepl, @birdspider? I can also do it, but you seem to understand the issue better than I do. Meanwhile I can make a translation |
Or, maybe that would still be a problem for when we are connecting to some other hostname? Is your workaround, forcing ipv4 better? I'm leaning towards that here. Please advice. 😄 |
Poor (dumb) man's way to wait for `close` messages to have been sent before destroying the socket. * Fixes #2310
Hi, @PEZ , sorry I didn't catch your replies, also: I'm not in a hurry with this issue. the way I see it, the problem is that
I think this would make sense currently, because nrepl (as started by calva, with default args) only ever binds to I also think that the server-started message is part of the problem (see below).
well, it might report anything, but with no extra args it hard-binds to failure scenario:
(*) I didn't check the msg I only see 3 solutions:
since in this case, calva starts the nrepl - I think the 2nd solution is the appropriate one PS: another workaround:
|
Thanks! With these commits, Calva would consistently use 127.0.0.1 instead of localhost, even while the nrepl server reports localhost: 73f172f...2310-ipv6-ambiguity However, if the nrepl server is started on some host, the connect string could be Your first workaround above #2310 (comment) seems to dodge all this and just force ipv4, which looks somewhat like what we want? |
I think this is appropriate default behavior since it guarantees compatibility with the auto-started nrepl. A custom connection is custom anyway - with user provided host.
true, but to my knowledge, remote apps, that support (as in resolved DNS) both ipv4 and ipv6 are usually listening on both (see i.e. apache config) in such a case a) it's either remote, probably resolved by dns (by the OS) (which practice could also return N addrs, some ip4, some ip6)
it (getent, dns resolve) seems to always prefer ipv6 - if enabled/configured
I think this would break all (incl. remote) ipv6-only host connections Hm, thinking about the problem a bit more, maybe nrepl should resolve |
maybe they do that, but "their" jvm returns ipv4: it can depend on how java is started (
|
if I do what calva does, in pure node-js (with an open nrepl)
there is no error, even though calva can't connect to the repl. if I use a nonexisting repl port, for illustration, node/net even errors on both IPs:
EDIT: native nodejs cmd nodejs=20.6.1, vscode nodejs=18.15.0 |
I think I found the "reason" this happend at all: as per vscode-versions there was a switch inside vscode bringing nodejs from Further, as per nodejs/node#39987 (and as explained in nodejs/node#40537 (comment)) node 17 resolves/returns addresses as delivered by resolver/OS - whereas previously (node<17) it ordered them ip4 first. |
possible fix in nrepl, returning the actual address diff --git a/src/clojure/nrepl/socket.clj b/src/clojure/nrepl/socket.clj
--- src/clojure/nrepl/socket.clj
+++ src/clojure/nrepl/socket.clj
@@ -207,9 +207,9 @@
(URI. (str transport-scheme
(when (instance? SSLServerSocket sock)
"s"))
nil ;; userInfo
- (-> sock .getInetAddress .getHostName)
+ (-> sock .getInetAddress .getHostAddress)
(.getLocalPort sock)
nil ;; path
nil ;; query
nil)))))) ;; fragment maybe @bbatsov has some ideas if this is to handle in nrepl or calva |
Thanks for doing all this research! Please consider reporting it on the nrepl repository. |
not sure if its my system/system-update but:
description
calva jack-in fails to connect (ECONNREFUSED).
I think because vscode chooses/returns
localhost
as ipv6::1
(maybe in addition to127.0.0.1
).However,
nrepl.cmdline
seems not to be started with ipv6 bindings (see below)calva repl log:
I do not know what changed - that makes vscode/calva use
::1
- it's not required for me/my case.manual setup works
see param
-b
, with0.0.0.0
it should bind to anylocaladdress, hence connecting when starting like this, works:The text was updated successfully, but these errors were encountered: