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

[/127.0.0.1:30535] Address in use #6730

Closed
JaroslavTulach opened this issue May 17, 2023 · 12 comments · Fixed by #6774
Closed

[/127.0.0.1:30535] Address in use #6730

JaroslavTulach opened this issue May 17, 2023 · 12 comments · Fixed by #6774
Assignees
Labels
-project-manager s-research-needed Status: the task will require heavy research to complete

Comments

@JaroslavTulach
Copy link
Member

I have downloaded https://github.com/enso-org/enso/releases/tag/2023.2.1-nightly.2023.5.17 release and tried to launch it:

~$ /enso-linux-2023.2.1-nightly.2023.5.17.AppImage
Electron application is ready.
╭ Starting the application 
│ ╭ Starting the backend process with the following options: . 
│ │ Backend has been spawned (pid = 160705).
│ ╰ Done in 5.4 ms. 
│ ╭ Starting the content server. 
│ │ Server started on port 8081.
│ │ Serving files from '/home/devel/tmp/.mount_enso-l1VDuon/resources/app.asar/assets'.
│ ╰ Done in 13.2 ms. 
│ ╭ Creating the window. 
[info] [2023-05-17T11:39:00.294Z] [org.enso.projectmanager.boot.ProjectManager$] Starting Project Manager...
timestamp=2023-05-17T11:39:00.439621Z level=ERROR thread=#zio-fiber-1 message="" cause="Exception in thread "zio-fiber-5" akka.stream.impl.io.ConnectionSourceStage$$anon$1$$anon$2: Bind failed because of java.net.BindException: [/127.0.0.1:30535] Address in use
        at org.enso.projectmanager.boot.ProjectManager.bindServer(ProjectManager.scala:298)
        at org.enso.projectmanager.boot.ProjectManager.mainProcess(ProjectManager.scala:74)
        at org.enso.projectmanager.boot.ProjectManager.runOpts(ProjectManager.scala:238)
        at org.enso.projectmanager.boot.ProjectManager.runArgs(ProjectManager.scala:122)
        Suppressed: java.net.BindException: [/127.0.0.1:30535] Address in use
                at [email protected]/sun.nio.ch.Net.bind0(Net.java)
                at [email protected]/sun.nio.ch.Net.bind(Net.java:459)
                at [email protected]/sun.nio.ch.Net.bind(Net.java:448)
                at [email protected]/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
                at [email protected]/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80)
                at akka.io.TcpListener.liftedTree1$1(TcpListener.scala:60)
                at akka.io.TcpListener.<init>(TcpListener.scala:57)
                at [email protected]/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
                at akka.util.Reflect$.instantiate(Reflect.scala:73)
                at akka.actor.ArgsReflectConstructor.produce(IndirectActorProducer.scala:101)
                at akka.actor.Props.newActor(Props.scala:226)
                at akka.actor.ActorCell.newActor(ActorCell.scala:616)
                at akka.actor.ActorCell.create(ActorCell.scala:643)
                at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:514)
                at akka.actor.ActorCell.systemInvoke(ActorCell.scala:536)
                at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:295)
                at akka.dispatch.Mailbox.run(Mailbox.scala:230)
                at akka.dispatch.Mailbox.exec(Mailbox.scala:243)
                at [email protected]/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
                at [email protected]/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
                at [email protected]/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
                at [email protected]/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
                at [email protected]/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

Are we really using the same fixed port? What if it is taken? What if one wants to run two Enso IDE on the same computer (by different user)? Shouldn't the port rather be dynamically allocated?

@Akirathan
Copy link
Member

Akirathan commented May 17, 2023

That seems like an issue of project-manager. There is a fixed port specific for project-manager in https://github.com/enso-org/enso/blob/develop/lib/scala/project-manager/src/main/resources/application.conf#L36. So currently, you can have just one project-manager per one machine. Isn't this intentional?

cc @radeusgd

GitHub
Hybrid visual and textual functional programming. Contribute to enso-org/enso development by creating an account on GitHub.

@Akirathan Akirathan added s-research-needed Status: the task will require heavy research to complete -project-manager labels May 17, 2023
@Akirathan Akirathan removed the triage label May 17, 2023
@radeusgd
Copy link
Member

@4e6 can you take a look at this?

@PabloBuchu
Copy link
Contributor

There is fixed project manager address in app/gui/src/constants.rs

/// Endpoint used by default by a locally run Project Manager.
pub const PROJECT_MANAGER_ENDPOINT: &str = "ws://127.0.0.1:30535";

We are also using this address in new dashboard. At least it would be good to somehow have it defined in one place because currently we have:

  • app/gui/src/constants.rs access by rust
  • /app/gui/config.yaml access by typescript in dashboard
  • lib/scala/project-manager/src/main/resources/application.conf access by project manager itself

@hubertp
Copy link
Collaborator

hubertp commented May 17, 2023

Like the predecessors mentioned, you probably have an instance of project-manager running already.

@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented May 17, 2023

Like the predecessors mentioned, you probably have an instance of project-manager running already.

Sure I do.

So currently, you can have just one project-manager per one machine. Isn't this intentional?

Relying on fixed port is wrong. First of all the address can be taken, second on a multi user machine, the project-manager instances started by different user are going to clash. This is fine when one starts the project-manager manually, but when it is launched by the IDE itself, it should allocate a random port.

@somebody1234
Copy link
Contributor

keep in mind that if someone does make this change on scala's side, changes will also need to be made on both electron (running the project manager with the appropriate port) and the GUI (adding a configuration option for the port) and the new dashboard (passing through the configuration option)

(this can be done in a separate PR, this is mostly a note that this would need to be implemented in multiple places)

@wdanilo
Copy link
Member

wdanilo commented May 17, 2023

The port should be communicated to GUI during initialization. As @JaroslavTulach mentioned, relying anywhere on hardcoded ports is wrong. The same applies to our GUI-side server, which starts at 8080 if it's free and searches for a free port if it's occupied. We should allow for multiple instances of Enso running side by side so any hardcoding of ports is very bad and needs to be fixed on GUI side ASAP. @somebody1234 could you make a ticket for it, please?

@somebody1234
Copy link
Contributor

@wdanilo a ticket on cloud-v2? or a new one on this repo, but with a proposed solution? or something else?

@wdanilo
Copy link
Member

wdanilo commented May 23, 2023

@somebody1234 up to you - sorry for super late reply. We just need to fix that, while tickets are mainly for us. So if you feel a ticket fits better one repo, just create it there :) cloud-v2 should definitely have security-related tickets that if written publicly could do some harm to users. Regarding other tickets - it's up to you to decide where the ticket fits better :)

@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Aug 9, 2023

FYI: I've just tested the behavior with https://github.com/enso-org/enso/releases/tag/2023.2.1-nightly.2023.8.2 and it is still the same. When the port 30535 is occupied, the IDE cannot start project-manager and doesn't work. Expected behavior: the local project manager is and the IDE select different port and connect via it.

GitHub
Download Enso IDE Enso IDE is the main product of the Enso project. The packages are stand-alone, they contain both GUI and the backend. Download links:

Linux (AppImage);
macOS (DMG);
Windows (Ins...

@somebody1234
Copy link
Contributor

@JaroslavTulach #6774 has been reopened - not sure if it needs any tests or something, but it should be ready to test at least

@mergify mergify bot closed this as completed in #6774 Aug 25, 2023
mergify bot pushed a commit that referenced this issue Aug 25, 2023
- Closes #6730
- Changes config to allow environment variables to override server host and port
- Adds port scanning to Electron app to ensure the PM is started at a free port

# Important Notes
- `SERVER_PORT=abcd enso.AppImage` does NOT work. It would not be difficult to implement, but it probably needs discussion on how exactly it should be implemented - for example, `SERVER_PORT` is quite a generic name, should the Electron app pass though something like `ENSO_PM_SERVER_PORT` to the PM as `SERVER_PORT` instead?

:warning: Port scanning is *only* implemented in the JS frontend. It is not implemented:
- In Scala, because the JS/Rust code calling it needs to know the port as well. There shouldn't be any problems with adding port scanning though, if that's desired
- In Rust, because I'm not sure parsing the host and port from a string is a good idea.
- (This also applies to JS, but it *must* work in JS, and port scanning is already a dependency there so it's quite a bit easier)

- QA *will* need a new PM (`sbt buildProjectManagerDistribution` or `./run backend sbt` -> `buildProjectManagerDistribution`), and the path must be supplied as: `-engine.project-manager-path=path/to/new/pm/here`
@github-project-automation github-project-automation bot moved this from ❓New to 🟢 Accepted in Issues Board Aug 25, 2023
@JaroslavTulach
Copy link
Member Author

Are we really using the same fixed port? What if it is taken? What if one wants to run two Enso IDE on the same computer (by different user)? Shouldn't the port rather be dynamically allocated?

I can confirm my inquiry is fixed. Thank you. When I execute project-manager and suspend it:

enso$ ./built-distribution/enso-project-manager-0.0.0-dev-linux-amd64/enso/bin/project-manager 
[info] [2023-08-28T06:21:08.604Z] [org.enso.projectmanager.boot.ProjectManager$] Starting Enso Project Manager
Version:    0.0.0-dev
Built with: scala-2.13.11 for GraalVM 17.0.7
Built from: develop* @ b8edf6a3582b35573dbd824ca04d21b39d4be910
Built on:   Linux (amd64)

[info] [2023-08-28T06:21:08.624Z] [org.enso.projectmanager.boot.ProjectManager$] Started server at 127.0.0.1:30535, press enter to kill server
^Z
[1]+  Stopped                 ./built-distribution/enso-project-manager-0.0.0-dev-linux-amd64/enso/bin/project-manager

which blocks the port 30535 and then launch ./enso-linux-2023.2.1-nightly.2023.8.28.AppImage I can see it starts its own new project-manager on port 30536. E.g. it finds an empty port to work on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-project-manager s-research-needed Status: the task will require heavy research to complete
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

8 participants