-
Notifications
You must be signed in to change notification settings - Fork 117
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
Node "writer error" on reception of UDP message to be transmitted over Websocket #185
Comments
Hi @ahfontaine, sorry to hear you're getting an error. It's hard to know what the issue might be without seeing your implementation. Can you post simplified example of your code so that I can take a look and try it out, along with some example data that you're sending from Unity? Thanks! |
It's still really hard for me to test this given the environment you're using. I assume I'd need a license for Unity and your code there to actually see what's being sent and debug it? This is interesting, though. The error you're seeing is quite deep in the guts of osc.js, and is one of those "this should never happen" moments. It's totally a bug in osc.js that this isn't caught and a more helpful error message presented. However, this error suggests that somehow an invalid OSC argument type is being received. osc.js supports all the OSC 1.0 and 1.1 argument types. Is it possible that somehow your Unity code is sending an non-spec-compliant OSC message? Can you simplify your system for testing purposes and reproduce the error when only receiving OSC messages from Unity to Node.js via UDP? In other words, omit the Web Socket server and relaying of messages from the UDPPort to the WebSocket. Are you able to receive messages from unity and log them to the Node.js console successfully? |
A free license of Unity is all you would need to test this, and trying something like the SampleScene of OSCJack or demo 8 of extOSC (the one used in that screenshot above) is more than enough. You could simply also use the UDP-Browser demo or any other examples from the examples repo to check out what's going on. I was able to pinpoint my issue as to the Node back-end because of the following :
So it really points out in the direction of Node at that point. For the OSC libraries, I'm getting the same issues on both OSCJack and extOSC, both free plugins for OSC for Unity. My tests are based on their internal demo. They are both sending spec-defined OSC as per their description but since it seems like the UDP -> Node part is working, I have some doubts in regards to the signal being out of spec. Here is the Node code in its entierety :
It is primarily based on the UDP-Browser example in the example repo, with some tweaks to handle keeping track of how many clients are open and Usernames. Oh and maybe a detail that I'm thinking might be a cause for issues : I'm using React for the front-end.
It's not important and we found this workaround for the time being, but it was odd that it was the same undefined writer issue once again. Hope this clarifies it a bit! |
There's definitely a bug or two in here somewhere, I'll just need some time to take a look and trace through the code. In terms of your last code snippet, I think the issue there is that you can't send messages on a Port until it has fired its |
Hi @colinbdclark, Thanks for checking out my code. |
Hi @ahfontaine, So just to confirm, all of your issues were resolved by waiting for the ready event? If so, I'll update the example code accordingly, and that gives me a much clearer path to addressing the issue of clearer error messages in this case. There's not much to the osc.Relay implementation, and I haven't extensively documented it because I haven't wanted to strongly promote its use. I may remove it in a future version of osc.js, since I think this sort of relaying logic can get complex quickly, and is best implemented in application code. For the use case you describe, I think you should be able to implement a custom relayer quite easily, but the osc.Relay object won't be of much help. |
Oh also,
Considering I based most of my node logic on the UDP-Browser/Browser examples in the example repos, would you have a recommendation on what would be the best practice to do a similar thing (Bridge in the middle sort of approach instead of Point to point)? |
Hi @colinbdclark,
if I remove the "true" and send a message from Unity to the back-end/websocket : |
Hi @ahfontaine great detective work. So I think the issue is that your ports don't match; you've got your UDPPort set up to require type metadata, but your WebSocketPort does not. I expect that as long as you're using the same format for both Ports, it will work fine. In general, you should always use type-annotated messages ( There's still a bug here, regardless, which I will try to track down. |
I've added a unit test to the test suite for |
I've also filed #186 to track the issue with the examples. |
Hi,
I'm trying to get Unity and a Web App to be linked by OSC.Js
I based myself on the UDP-Browser demo to make myself the webapp.
Transmitting Websocket data over to Unity works without any issues.
Transmitting UDP data from Unity over to the Node server without any websocket connection will work as well.
However, transmitting UDP data from Unity over to the Node server while a single Websocket connection is connected will crash the node process with this error.
Is there something I'm misunderstanding in my use case?
The text was updated successfully, but these errors were encountered: