godotengine/godot-vscode-plugin

Default LSP server port of plugin doesn't match with default port of Godot 4

tymbaca opened this issue ยท 14 comments

Godot version

4.0.2.stable.official

VS Code version

1.77.3 (Universal)

Godot Tools VS Code extension version

1.3.1

System information

MacOS Monterey (12.6.3)

Issue description

By default Godot 4 Language Server port is set to "6005", whereas Godot Tools default is set to "6008".

So can't connect to Godot 4's Language Server via VS Code without changing either Godot Tools settings or Godot Language Server settings.

Steps to reproduce

  • Install Godot Tools VS Code extension
  • Install Godot 4 (make sure "Network/Language Server" settings are set to default
  • Try to connect to LSP via VS Code

For reference, this is why the default port was changed:

The LSP port changed in Godot 4, as the one used in Godot 3 conflicted with the normal debugger port when using multiple Godot instances.

godotengine/godot#75683

FYI, these lines in godot-vscode-plugin need to be changed (godotTools.lsp.serverPort): https://github.com/godotengine/godot-vscode-plugin/blob/master/package.json#L182-L186. Found while I was fixing vim-lsp-settings, but I don't use vscode so I'm not making a PR.

Godot 3 users of this plugin can change to use port 6005 in editor -> editor settings -> network -> language server -> remote port.

Here's the port number in Godot4's code:
https://github.com/godotengine/godot/blob/master/modules/gdscript/language_server/gdscript_language_server.h#L47-L48

Hi there, can this issue be pinned in the interim? The impression this gives to users at the moment is that this extension simply doesn't work. Unless I missed something, there's nothing in the README about this and it will simply fail for all users of Godot 4.

jst4rk commented

I have the same port configured in both and does not work at all, I even change the porotol to ws but nothing happens
I'm using the latest version of VSCode and Godot 4.1

I have the same situation on my macos ventura. Godot 4.1.1 and godot-tools 1.3.1, I have configured port 6005 and vscode connected godot, but when launch debug in vscode๏ผŒgodot-tools always report error "Failed to launch Godot instance: Error: Command failed: ... "

Can confirm that the address is set to 127.0.0.1:6005 in both Godot and VS Code and VS Code hangs forever on "Initializing" with the message "Connecting to the GDScript language server at 127.0.0.1:6005". (Godot 4.1, OSX). The project is open in Godot.

Can confirm that the address is set to 127.0.0.1:6005 in both Godot and VS Code and VS Code hangs forever on "Initializing" with the message "Connecting to the GDScript language server at 127.0.0.1:6005". (Godot 4.1, OSX). The project is open in Godot.

For me opening the project's folder in VSCode solves it

torves commented

Godot requires the address to be of the format <protocol>://<host/ip>:<port>.
The default config does not include the <protocol> (http) in the launch.json and must be added manually.
Temporary fix is to edit your launch.json file and change the "address": "127.0.0.1" to "address": "http://127.0.0.1".

Also ensure you have set the "godot_tools.editor_path" property in your settings.json if it is not in your environment variables path.

The next extension release, 1.4.0, will solve this in multiple ways.

When using Godot 3.6 or 4.2, a new headless LSP mode will be available that spawns a new language server specifically for each workspace. (#488)

#511 adds a port fallback mechanism to automatically find the right port, which makes everything Just Work when using default settings.

Can we test this? I pulled down the master branch and built the extension, and it claims to try to start a headless background LSP instance when set up to do so, but it never works. It just fails every time. Are there logs that I can look into to see if why it fails to start?

I will post some screenshots this evening.

It just fails every time.

Headless LSP mode checks to make sure it can run and displays errors if it detects that something is wrong, it shouldn't "just fail".

It just fails every time.

Headless LSP mode checks to make sure it can run and displays errors if it detects that something is wrong, it shouldn't "just fail".

I'm guessing I've messed up my configuration in some way that is thwarting it. I would like to help sort out what I did wrong before 100,000 users hit it and repeat my mistakes.
I'm away from my system today, but I'll work through it again tonight or tomorrow and post screenshots.

I would like to help sort out what I did wrong before 100,000 users hit it and repeat my mistakes.
I'm away from my system today, but I'll work through it again tonight or tomorrow and post screenshots.

That would be great. Please open a new issue for this whenever you get back, and I'll make sure it gets sorted out.

Extension version 2.0.0 has been published, which automatically finds the correct LSP port in most cases.

If you're still experiencing issues connecting to the LSP, please revert all the LSP port settings to their default values (both in VSCode and in the Godot Editor settings) and try again.