nrepl
nrepl copied to clipboard
Adopt default port
7888 is "free", at least in IANA.
Most users want to put an nREPL port on their app, and that should always be on a typical port. Auto-selection of a port is only desirable in tooling scenarios, and tooling authors can pass an argument to start-server.
This will change the behaviour of (start-server).
(from https://dev.clojure.org/jira/browse/NREPL-3)
How should this be handled?
Here: https://github.com/nrepl/nREPL/blob/master/src/clojure/clojure/tools/nrepl/cmdline.clj#L70
and here: https://github.com/clojure-emacs/nREPL/blob/master/src/clojure/clojure/tools/nrepl/server.clj#L140
start-server is started with the port 0, the first available port.
Should it now start with port 7888 by default and if that port isn't free, then fall back to port 0 ?
What does having a /default/ port buy us or nREPL as a library? Many Clojure tools benefit from NOT having a standard port they expect to bind, and consequently one is able to have many nREPLs on or port forwarded to one machine fairly easily.
@arrdem Did you see what Chas had written?
Most users want to put an nREPL port on their app, and that should always be on a typical port. Auto-selection of a port is only desirable in tooling scenarios, and tooling authors can pass an argument to start-server.
Seems the point of this to have a default port when running an embedded nREPL server only.
@bbatsov Ah. That makes sense as a minor convenience.
https://tools.ietf.org/html/rfc6335#section-8 seems relevant
https://www.iana.org/form/ports-services is the request form
My 2c: I actually was thinking that a mechanism like .nrepl-port would be sufficient, most of the tooling now understands that - for local nrepl that is.
For remote ones, cider can store host:port pairs so it is basically just a matter of adding your own. Probably using a default like that would be a bit overkill?
My 2c: I actually was thinking that a mechanism like .nrepl-port would be sufficient, most of the tooling now understands that - for local nrepl that is.
Yeah, that solves the problem for local development for most people. We should certainly start creating the file in nrepl.cmdline as well.
My 2c: I actually was thinking that a mechanism like
.nrepl-portwould be sufficient, most of the tooling now understands that - for local nrepl that is.
In remote/docker/devcontainer scenarios you need to specify "port forwarding" before starting things. And this works with a "fixed portnumber", not dynamic. Example: https://code.visualstudio.com/docs/devcontainers/containers#_forwarding-or-publishing-a-port
In this scenarios it is as well guarantied/foreseen that only one nrepl server runs per container
So I would support a notion of a "default nrepl" port.