Hallo everyone!
I am currently working on a team project at university (without software version control system for several reasons) that amongst many other things includes sending wind zone intensities via OSC messages out of Unity to real wind machines. The OSC plugin I use it called UnityOSC by Jorge Garcia.
The workflow is such that the whole project is updated by one team mate and then send as a whole to the next for further updates. This might sound very convoluted, but for this particular project is works nicely.
Expect for one thing I ran into a couple of updates back:
Sometimes (not with every project update) when I receive an updated project, even one that only has some terrain modifications done, the OSC plugin fails to initialize and says the following:
Exception: Can’t create client at IP address 127.0.0.1 and port 5555.
UnityOSC.OSCClient.Connect () (at Assets/OSC/OSCClient.cs:80)
UnityOSC.OSCClient…ctor (System.Net.IPAddress address, Int32 port) (at Assets/OSC/OSCClient.cs:38)
OSCHandler.CreateClient (System.String clientId, System.Net.IPAddress destination, Int32 port) (at Assets/OSCHandler.cs:153)
OSCHandler.Init () (at Assets/OSCHandler.cs:96)
I already contacted the author of the plugin, but he couldn’t help me. He suspected that Unity and not the plugin is the problem here.
I think his assumption has some merit, because this is what let’s me get around the error (although it hardly is a long term solution):
- Export the whole project as a package
- Create a new empty project
- Import the package
OSC Plugin works again!
Do you guys have any idea what might be causing the OSC plugin to fail and why the above mentioned workflow solves the problem? Could it be invalid meta data that gets properly updated upon importing into a new project?
I’m puzzled as to why this happens and I’m feeling deeply uncomfortable to have such an unstable part in a project that fails so unpredictably.
Your help is very much appreciated!!
Thanks a lot!
eStudent
5 Answers
5
I’ve never encountered UnityOSC before. The errors you get suggest that the plugin is not able to create a network connection, which might mean that a previous run of Unity has created a client on port 5555 and for some reason that client has never terminated. I’d try a reboot and see if that sorted it. Then start to look and see if there are any apps that can tell you what network ports are in use by which apps. (Something like netstat on a Mac.). There might be an app, or process recorded as using port 5555, in which case figure out a way of ending that process, again, on a Mac I’d use kill.
Thanks Graham. But no, rebooting doesn’t help
I don’t think a previous client is blocking the port. I have several project versions on my PC, in some the plugin works in some it doesn’t. If something is blocking a port, then even the working versions should fail to create a client. In one and the same Windows session I can do the following:
- First open a project in which the plugin fails → client can’t be created
- Afterwards open a project in which the plugin works → client can be created
- Open a project with failing plugin again → client can’t be created
That doesn’t indicate a blocked port IMO.
Also when I change the script to use a different port than 5555, the plugin still fails.
I encountered an issue where by i’d called OSCHandler.Instance.Init() multiple times. This was due to putting that particular line on a behaviour that was attached to multiple objects. I then got the "can’t connect to port " error.
I updated the code to the following so it was only called once. You could equally put this code in another script.
public static OSCHandler Instance
{
get
{
if (_instance == null)
{
_instance = new GameObject ("OSCHandler").AddComponent<OSCHandler>();
_instance.Init ();
}
return _instance;
}
}
I got the same exact problem.
I found the problem persists in a document in the project/Library folder. After closing the project and renaming the Library folder, it gets rebuild automatically. After this the OSC server is set up again by opening the project. It seems one of the files gets corrupted one way or another, I didn’t find out which one it was exactly though.
In case anyone comes across this issue in the future, a solution I found was to set the platform destination as ‘PC, Mac & Linux standalone’. Initially my project was set to build for the ‘web player’ platform. As to why this solved the issue, I have no clue. Perhaps someone can explain?
I also encountered the ‘can’t connect to client’ error message but that was because the client wasn’t open and running.