Skip to content

ConnectFailure occurs during the building C# code in Unity. #18

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

Closed
And165KMT opened this issue Apr 14, 2025 · 8 comments
Closed

ConnectFailure occurs during the building C# code in Unity. #18

And165KMT opened this issue Apr 14, 2025 · 8 comments
Labels
enhancement New feature or request

Comments

@And165KMT
Copy link

mcp calls script when the server is not accepting connections (such as during compilation), the process is interrupted. Is there a way to avoid it, such as by waiting?

Use VSCode Copilot Agent

Error Code
Failed to ensure server installation: Error: ConnectFailure (接続済みの呼び出し先が一定の時間を過ぎても正しく応答しなかったため、接続できませんでした。または接続済みのホストが応答しなかったため、確立された接続は失敗しました。

UnityEngine.Debug:LogError (object)
UnityMcpBridge.Editor.Helpers.ServerInstaller:EnsureServerInstalled () (at ./Library/PackageCache/com.justinpbarnett.unity-mcp@cbe9b3a2f0/Editor/Helpers/ServerInstaller.cs:48)
UnityMcpBridge.Editor.UnityMcpBridge:Start () (at ./Library/PackageCache/com.justinpbarnett.unity-mcp@cbe9b3a2f0/Editor/UnityMcpBridge.cs:63)
UnityMcpBridge.Editor.UnityMcpBridge:.cctor () (at ./Library/PackageCache/com.justinpbarnett.unity-mcp@cbe9b3a2f0/Editor/UnityMcpBridge.cs:53)
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes (System.Type[])

@CoderGamester
Copy link
Owner

unfortunately no @And165KMT
Unity doesn't run any code while compiling.
This means the websocket will be closed and requires reconnection by the Node.JS server.

The Node.JS server is already waiting for reply for 10sec to allow cases where the Unity's main thread is on hold to then execute the code, but situations like compile block are not possible to solve with Unity in it's current form

@CoderGamester CoderGamester added the wontfix This will not be worked on label Apr 14, 2025
@syntagmastudios
Copy link

Today im experiencing the Server being closed every 3 minutes resulting in having to close vcode and start again. Its happening when AI is modifiying a script.

@CoderGamester CoderGamester added enhancement New feature or request and removed wontfix This will not be worked on labels Apr 23, 2025
@CoderGamester
Copy link
Owner

I see, that is a bad workflow to work on
Will look into improve it

@CoderGamester
Copy link
Owner

@syntagmastudios I just pushed a fix for this issue with version 1.0.1
Please check it out if it improves your workflow

@syntagmastudios
Copy link

syntagmastudios commented Apr 25, 2025 via email

@nowsprinting
Copy link
Contributor

Hi @CoderGamester , I'm very excited about this feature!

I tried v1.0.1.
When I edited the code in IDE (Rider). Unity finishes building in the background, the bridge server still shows "Server Offline". It remained like this unless I moved focus to the Unity editor.
Of course, Can't connect from the MCP server.

When the build finished, the method with the [InitializeOnLoadMethod] attribute was called.
Can you restart the server at this point?

@CoderGamester
Copy link
Owner

@nowsprinting that is what is happening
the Unity websocket Server automatically restarts

Now, the Node.JS MCP server will automatically reconnect the websocket after invoking another prompt call

@CoderGamester
Copy link
Owner

#25 approved and merged
closing the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants