Communication between p5js and processing

Wondering if there’s a good solution for back and forth communication between a p5.js server running on node and a processing sketch that people think work pretty flawlessly.

I’ve tried UDP/OSC but js has 2000 ways to do that. I’ve tried websockets, doesn’t support socket.io but I’m having issues with connecting a second time if I close out the connection (there’s no easy way to close the connection using the websockets library for Processing (java)?) And I’ve tried simple get requests – Javascript side is super easy, but it ends up being a little one way, since Processing doesn’t handle the get requests in a way that makes any sense…

Looking for any examples… Thanks!

To clarify, your server is running node. P5js does not have any server features. You can use it in the backend for sure, but it is not doing the serving part.

Can you provide more details of what you want to do? Do you want to send a single notification? Multiple notifications? Do you want to have an open connection (you mention using sockets). What type of data are you transferring between your P3 java sketch and your server app? Images? One? or a stream, like a video? Are you doing this in your local computer but then you are planing to migrate it to a server later on?

Kf

1 Like

Thanks for the response, and sorry it’s not clear (it’s one of those projects that makes sense in your head but when you try to explain it…)

I think I have websockets working, but basically it needs to be able to send basic strings so that each side can get a specific view state ready. It’s an ipad open on the p5 client page, with a UI that’s just buttons. When the button is pressed (ipad), it tells processing (a monitor) to go get a new view ready, with a callback that it’s ready – then the ipad updates its state.

So, it’s seemingly easy and simple… but it hasn’t been. Been looking into spacebrew but seems perhaps overkill…

I think you need sockets. No experience with sockets in p5js. Did you check this page: https://github.com/processing/p5.js/wiki/p5.js,-node.js,-socket.io

To clarify, your computer is the host running node.js and Processing, right? The iPad is connecting to it. Everything is happening within the same network, as within the same wifi network?

Kf

Yeah I think you’re right. I’ll dive deeper with it since I think it’s probably that I screwed something up. And yes, the computer is running both the server and processing. the iPad is just navigating to the local ip address, and port.

Hello! I’ve the same problem: are you find a solution with sockets? My computer is running both too, the server and processing, but i don’t have access to the server from Processing. Any information welcome, thanks!