# Connect to Socket.io

**URL:** <https://discourse.processing.org/t/connect-to-socket-io/7660>\
**Category:** Libraries\
**Created:** [January 19, 2019, 8:53pm UTC](https://discourse.processing.org/t/connect-to-socket-io/7660 "2019-01-19T20:53:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quillbert1](https://avatars.discourse-cdn.com/v4/letter/q/f475e1/32.png) [@Quillbert1](https://discourse.processing.org/u/Quillbert1)\
**Post date:** [January 19, 2019, 8:53pm UTC](https://discourse.processing.org/t/connect-to-socket-io/7660/1 "2019-01-19T20:53:43Z")

</div>

I was wondering if it is possible to connect a processing sketch using the websockets library to [socket.io](http://socket.io). I tried it and got an error.

---

<div class="post-metadata">

**Author:** ![figraham](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/figraham/32/4161_2.png) [@figraham](https://discourse.processing.org/u/figraham)\
**Post date:** [January 19, 2019, 10:03pm UTC](https://discourse.processing.org/t/connect-to-socket-io/7660/2 "2019-01-19T22:03:14Z")

</div>

[Dan Shiffman did a video series on this](https://www.youtube.com/watch?v=bjULmG8fqc8&list=PLRqwX-V7Uu6b36TzJidYfIYwTFEq3K5qH). If that doesn’t help, could you describe what you’re trying to accomplish? Post your code and the error you’re getting.

---

<div class="post-metadata">

**Author:** ![Quillbert1](https://avatars.discourse-cdn.com/v4/letter/q/f475e1/32.png) [@Quillbert1](https://discourse.processing.org/u/Quillbert1)\
**Post date:** [January 21, 2019, 12:50am UTC](https://discourse.processing.org/t/connect-to-socket-io/7660/3 "2019-01-21T00:50:40Z")

</div>

I’m trying to get a processing websocket server to read and print messages sent over the example [socket.io](http://socket.io) server:  
[https://github.com/socketio/chat-example](https://github.com/socketio/chat-example)

Here is my code:

```auto
import websockets.*;

WebsocketClient w;

void setup() {
 size(200,200);
 w = new WebsocketClient(this, "ws://localhost:3000");
}

void webSocketEvent(String msg) {
 println(msg); 
}

```

And here is my error:

```auto
[Animation Thread] INFO org.eclipse.jetty.util.log - Logging initialized @1855ms
[WebSocketClient@48536915-28] WARN org.eclipse.jetty.websocket.client.io.UpgradeConnection - read - EOF Reached
onError(EOFException: Reading WebSocket Upgrade response)
java.io.EOFException: Reading WebSocket Upgrade response
	at org.eclipse.jetty.websocket.client.io.UpgradeConnection.read(UpgradeConnection.java:267)
	at org.eclipse.jetty.websocket.client.io.UpgradeConnection.onFillable(UpgradeConnection.java:196)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
	at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
	at java.lang.Thread.run(Thread.java:748)

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [January 27, 2019, 1:35am UTC](https://discourse.processing.org/t/connect-to-socket-io/7660/4 "2019-01-27T01:35:37Z")

</div>

Were you able to resolve your problem?

I browsed previous websockets discussion on the old forum:

> **[Processing 2.x and 3.x Forum](https://forum.processing.org/two/search?Search=websockets)**
>
> Processing is an electronic sketchbook, a language and a worldwide community. This is its forum.

but wasn’t sure if they were relevant to your issue.

Forum members with websockets experience might be found in previous threads here:

[https://discourse.processing.org/search?q=websockets](https://discourse.processing.org/search?q=websockets)

---

<div class="post-metadata">

**Author:** ![Quillbert1](https://avatars.discourse-cdn.com/v4/letter/q/f475e1/32.png) [@Quillbert1](https://discourse.processing.org/u/Quillbert1)\
**Post date:** [January 27, 2019, 8:15pm UTC](https://discourse.processing.org/t/connect-to-socket-io/7660/5 "2019-01-27T20:15:19Z")

</div>

I haven’t been able to fix it yet, I have been working on other things. I wasn’t able to find anything easily on the old forum. I will have to dig deeper. Thanks!

---

<div class="post-metadata">

**Author:** ![Quillbert1](https://avatars.discourse-cdn.com/v4/letter/q/f475e1/32.png) [@Quillbert1](https://discourse.processing.org/u/Quillbert1)\
**Post date:** [February 2, 2019, 10:54pm UTC](https://discourse.processing.org/t/connect-to-socket-io/7660/6 "2019-02-02T22:54:54Z")

</div>

Update: I tested with ws, and my everything worked fine. It must have something to do with [socket.io](http://socket.io)

---

<div class="post-metadata">

**Author:** ![Quillbert1](https://avatars.discourse-cdn.com/v4/letter/q/f475e1/32.png) [@Quillbert1](https://discourse.processing.org/u/Quillbert1)\
**Post date:** [February 5, 2019, 5:09am UTC](https://discourse.processing.org/t/connect-to-socket-io/7660/7 "2019-02-05T05:09:29Z")

</div>

Another update: Changing the Url has made it possible to receive messages, although they are in weird formats. I changed the url to “ws://localhost:3000/socket.io/?EIO=3&transport=websocket”. Sending also doesn’t work.
