Skip to content
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

Port Binding Issues - Stopping playmode does not seem to close ports #34

Open
Nolram12345 opened this issue May 1, 2022 · 10 comments
Open
Assignees
Labels

Comments

@Nolram12345
Copy link

As the title describes, I have been having issues with starting playmode with OscJack (and OscJackVS) where, after ending playmode and starting it again, it would not be able to open the ports and would complain about them already being bound to. A full restart of Unity is required to work around this issue, and it is not consistent in every case - sometimes restarting works again, sometimes it does not.

Unity Version : 2021.3.0f1

@keijiro keijiro self-assigned this May 2, 2022
@keijiro
Copy link
Owner

keijiro commented May 2, 2022

Does it reproduce with the sample project in this repository?

@Nolram12345
Copy link
Author

I have so far not being able to do such, however I have not tested extensively yet.

@antoniohof
Copy link

Also have this

@antoniohof
Copy link

OK, this happens only with certain ports that are not supposed to be used for OSC. Try changing them.

@cabbibo
Copy link

cabbibo commented Mar 6, 2023

@antoniohof what port do you use? I have been hitting this problem very explicity, to the point where if I run anything in edit mode, I have to restart unity every time I save a file :/

@Tehenauin
Copy link

OK, this happens only with certain ports that are not supposed to be used for OSC. Try changing them.

As cabbibo says, can you share what ports work for you?

I am having the same problem. Is there maybe some way to close existing ports manually?

@Tehenauin
Copy link

Tehenauin commented Mar 21, 2023

OK, It was my own fault.
In my case it didn't have to do anything with the port number. (I am using port 1234)

For my custom event receiver I copied the RegisterCallback() and UnregisterCallback() Logic from the OSCEventReceiver. But somehow I forgot to call the UnregisterCallback on OnDisable(). After adding that, it works fine again.

Edit:
I take it back, it is still not working. It just appears quite irregularly.

@cabbibo
Copy link

cabbibo commented Mar 21, 2023 via email

@cabbibo
Copy link

cabbibo commented Mar 21, 2023 via email

@Tehenauin
Copy link

Tehenauin commented Mar 23, 2023

I think I found a soloution.

Since unity doesn't call the servers dispose method (which is in charge of closing the running Thread), you have to do it by yourself. Easiest is probably to call it from a monobehaviours OnDestroy method. Ideally the behaviour that creates the server. For me it looks like this:

private void OnDestroy()
    {
        var server = OscMaster.GetSharedServer(currentPort);
        server?.Dispose();
    }

I hope this is the correct answer. But so far its looking good.

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

No branches or pull requests

5 participants