godotengine / godot-vscode-plugin

Godot development tools for VSCode
MIT License
1.6k stars 170 forks source link

Couldn't connect to the lang.server at random port #713

Closed ParadoxV5 closed 2 months ago

ParadoxV5 commented 2 months ago

Godot version

v4.3.stable.steam [77dcf97d8]

VS Code version

Version: 1.93.0 (system setup)

Godot Tools VS Code extension version

v2.1.0

System information

Windows 11

Issue description

The extension fails with a random port number unless it’s reloaded after opening the VSCode Settings window (placebo) until half a minute after Godot Engine starts.

Couldn't connect to the GDScript language server at 127.0.0.1:random number. Is the Godot editor or language server running?

Yes, random port number, differing each failed retry, as if reading from an uninitialized uint16.

Steps to reproduce

I opened my project VSCode (from Godot or manually) after opening it in Godot Editor.

settings.json

{
"godotTools.editorPath.godot4": "C:/Program Files (x86)/Steam/steamapps/common/Godot Engine/godot.windows.opt.tools.64.exe",
"godotTools.inlayHints.gdscript": true,
"godotTools.lsp.autoReconnect.attempts": 2,
"godotTools.lsp.headless": true,
"godotTools.lsp.serverPort": 6005,
"godotTools.scenePreview.previewRelatedScenes": "anyFolder"
}
DaelonSuzuka commented 2 months ago

Yes, random port number

Headless LSP mode uses a random, high, unoccupied port because the entire purpose is to allow you to open multiple Godot projects in separate VSCode windows without port conflicts.

I suspect that the problem is that you changed godotTools.lsp.autoReconnect.attempts to 2 from it's default value of 10. Starting the engine (even in Headless mode) can easily take more than 6 seconds, so I don't know why you would set the attempts to 2.

ParadoxV5 commented 2 months ago

Thank you for your explaination.

Starting the engine (even in Headless mode) can easily take more than 6 seconds, so I don't know why you would set the attempts to 2.

I expected the connection to be consistent in cases where it should suceed (not considering boot duration vs. timeout). I dropped this setting to reduce attempts on cases where it should fail (e.g., #696)

DaelonSuzuka commented 2 months ago

Did fixing godotTools.lsp.autoReconnect.attempts solve your problem?

ParadoxV5 commented 2 months ago

Seems that it is because of the slow startup time of the lang.server. With 10 attempts, there was no error message. With 2 attempts, it eventually succeds after clicking reconnect half a dozen times.

Opening the settings window is a placebo because it took time.

DaelonSuzuka commented 2 months ago

Yes, that's why the default value is 10.

DaelonSuzuka commented 2 months ago

@ParadoxV5 Are you still experiencing a Language Server connectivity problem?

ParadoxV5 commented 2 months ago

@ParadoxV5 Are you still experiencing a Language Server connectivity problem?

I have not had connectivity problems recently; but I would like the plugin adjusted to not have to rely on a large number of reconnect attempts.

DaelonSuzuka commented 2 months ago

but I would like the plugin adjusted to not have to rely on a large number of reconnect attempts.

No.