nrepl icon indicating copy to clipboard operation
nrepl copied to clipboard

Adopt default port

Open cemerick opened this issue 8 years ago • 7 comments

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)

cemerick avatar Nov 06 '17 20:11 cemerick

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 ?

dotemacs avatar May 17 '18 21:05 dotemacs

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 avatar May 18 '18 03:05 arrdem

@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 avatar May 18 '18 05:05 bbatsov

@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

arrdem avatar May 19 '18 16:05 arrdem

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?

arichiardi avatar Aug 22 '18 19:08 arichiardi

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.

bbatsov avatar Aug 23 '18 06:08 bbatsov

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.

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.

behrica avatar May 15 '24 11:05 behrica