# Communication between p5js and processing

**URL:** https://discourse.processing.org/t/communication-between-p5js-and-processing/1444
**Category:** Libraries
**Created:** [July 2, 2018, 7:57pm UTC](https://discourse.processing.org/t/communication-between-p5js-and-processing/1444 "2018-07-02T19:57:13Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![proxycase](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/proxycase/32/624_2.png) [@proxycase](https://discourse.processing.org/u/proxycase)
#### Post date: [July 2, 2018, 7:57pm UTC](https://discourse.processing.org/t/communication-between-p5js-and-processing/1444/1 "2018-07-02T19:57:13Z")

</div>

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](http://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!

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [July 2, 2018, 8:43pm UTC](https://discourse.processing.org/t/communication-between-p5js-and-processing/1444/2 "2018-07-02T20:43:14Z")

</div>

> [@proxycase](#):
>
> p5.js server

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

---

<div class="post-metadata">

### Author: ![proxycase](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/proxycase/32/624_2.png) [@proxycase](https://discourse.processing.org/u/proxycase)
#### Post date: [July 2, 2018, 9:26pm UTC](https://discourse.processing.org/t/communication-between-p5js-and-processing/1444/3 "2018-07-02T21:26:54Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [July 2, 2018, 10:47pm UTC](https://discourse.processing.org/t/communication-between-p5js-and-processing/1444/4 "2018-07-02T22:47:45Z")

</div>

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](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

---

<div class="post-metadata">

### Author: ![proxycase](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/proxycase/32/624_2.png) [@proxycase](https://discourse.processing.org/u/proxycase)
#### Post date: [July 3, 2018, 5:05am UTC](https://discourse.processing.org/t/communication-between-p5js-and-processing/1444/5 "2018-07-03T05:05:22Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![matiasjl](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/matiasjl/32/7417_2.png) [@matiasjl](https://discourse.processing.org/u/matiasjl)
#### Post date: [December 8, 2019, 3:16am UTC](https://discourse.processing.org/t/communication-between-p5js-and-processing/1444/6 "2019-12-08T03:16:13Z")

</div>

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!
