Skip to content

Unity disconnects from node #28

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

Open
Darth-Carrotpie opened this issue May 5, 2025 · 5 comments
Open

Unity disconnects from node #28

Darth-Carrotpie opened this issue May 5, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@Darth-Carrotpie
Copy link

Unity is running Unity MCP server. I can initially connect without any issues.
After some time, the session gets disconnected (or errors out, not sure) from node server.
Then there is an option to manually:

  • Kill the server, try relaunching again.
  • Leave the old server hanging, run new server on different port, reconfigure client as well.
    Both options are annoying, manual and shouldn't happen in the first place...

The error is this, just for confirmation, but the reason is described above.

[MCP Unity] Failed to start WebSocket server: Only one usage of each socket address (protocol/network address/port) is normally permitted.
@CoderGamester
Copy link
Owner

This is indeed annoying @Darth-Carrotpie
Thank you for reporting

If I understand correctly, the node server disconnects with Unity websocket server. Is that correct?
To also confirm, does your MCP host (Cursor, Windsurf or Claude) reconnect with Unity MCP when you trigger a new prompt? (ex: send a console log to unity saying HELLO WORLD)

@CoderGamester CoderGamester added the question Further information is requested label May 5, 2025
@Darth-Carrotpie
Copy link
Author

If I understand correctly, the node server disconnects with Unity websocket server. Is that correct? To also confirm, does your MCP host (Cursor, Windsurf or Claude) reconnect with Unity MCP when you trigger a new prompt? (ex: send a console log to unity saying HELLO WORLD)

Could you please point me to how to test this? I mean - how to send the console log from the MCP client?

Btw, I've noticed yesterday that it also happens when Unity rebuilds/reloads domain.

@CoderGamester
Copy link
Owner

CoderGamester commented May 6, 2025

If I understand correctly, the node server disconnects with Unity websocket server. Is that correct? To also confirm, does your MCP host (Cursor, Windsurf or Claude) reconnect with Unity MCP when you trigger a new prompt? (ex: send a console log to unity saying HELLO WORLD)

Could you please point me to how to test this? I mean - how to send the console log from the MCP client?

Btw, I've noticed yesterday that it also happens when Unity rebuilds/reloads domain.

Simply ask to your MCP host (Claude, Windsurf, Cursor, Copilot, etc) with the following prompts:

  • "Send a console log message to Unity saying Hello World"
  • "Get me all the objects in the hierarchy scene in Unity"
  • "Select Main Camera object in the Unity scene"

Explanation:

  • Yes, when Unity domain reloads, it will close the Websocket server and thus cutting the connection with the MCP server unfortunately.
  • Fortunately there is a safe mechanism that auto restarts the websocket in Unity to accept new connections and commands immediately after the domain reload completes.
  • Invoking a console log tool or any other tool or resource, will reconnect with Unity and act as normal

@Darth-Carrotpie
Copy link
Author

Hello.

  • "Send a console log message to Unity saying Hello World"

Or similar prompts do nothing. It just cannot connect. And it seem obvious why, the server connection to unity is down. Ofc it wouldn't connect...

  • Fortunately there is a safe mechanism that auto restarts the websocket in Unity to accept new connections and commands immediately after the domain reload completes.
  • Invoking a console log tool or any other tool or resource, will reconnect with Unity and act as normal

Does not work. Unfortunately, when it breaks - it breaks forever. Only PC restart helps or probably also manually killing node.js server.
This makes it basically unusable, as the reload happens after every code change. Well perhaps just the first time, then it breaks and due to socket being 'used', never re-connects or 'starts' the server again.

Image

@CoderGamester
Copy link
Owner

thank you for the detailed information @Darth-Carrotpie
It is now my focus to fix this frustrated situation

Do you have the time to jump on a call?
I want to make sure I get as much information as possible to make it work the best for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants