# Error in Websockets Library

**URL:** https://discourse.processing.org/t/error-in-websockets-library/12550
**Category:** Libraries
**Created:** [July 7, 2019, 8:02am UTC](https://discourse.processing.org/t/error-in-websockets-library/12550 "2019-07-07T08:02:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![usufwasi](https://avatars.discourse-cdn.com/v4/letter/u/a4c791/32.png) [@usufwasi](https://discourse.processing.org/u/usufwasi)
#### Post date: [July 7, 2019, 8:02am UTC](https://discourse.processing.org/t/error-in-websockets-library/12550/1 "2019-07-07T08:02:11Z")

</div>

I am getting the following error when I run the example code for a websocket server.

**"The constructor “WebsocketServer(WebsocketServer, int, String)” does not exist"**.

The relevant code is as follows:

```auto

import websockets.*;

WebsocketServer ws;
int now;
float x,y;

void setup(){
  size(200,200);
  ws= new WebsocketServer(this,8080,"");
  now=millis();
  x=0;
  y=0;
}

```

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [July 7, 2019, 8:47am UTC](https://discourse.processing.org/t/error-in-websockets-library/12550/2 "2019-07-07T08:47:05Z")

</div>

yes, did you start from

> **[GitHub - alexandrainst/processing\_websockets: A web socket library, including...](https://github.com/alexandrainst/processing_websockets)**
>
> A web socket library, including both server and client, for Processing - GitHub - alexandrainst/processing\_websockets: A web socket library, including both server and client, for Processing

see also

> [@Convert JSON String to JSON Object and Parse all data](https://discourse.processing.org/t/convert-json-string-to-json-object-and-parse-all-data/10407/4):
>
> actually i understood your question like you get a JSON like string over network already but recreating the JSON array structure makes you problems, and i answer you should repair the sending as {"value": "[[...], [...], [...], [..]]"} is not JSON conform OR i manage the read and restore anyway but the precondition is that that is the string you get? so please change void webSocketEvent(String msg) { println("\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*"); to void webSocketEvent…

* * *

test:

```auto
// https://github.com/alexandrainst/processing_websockets
// file websocket_server2.pde
// processing 3.5.3 on win7 / 64bit

import websockets.*;

WebsocketServer wss;
String outmsg="Server mouse click";

void setup() {
  size(500, 500);
  wss = new WebsocketServer(this, 8025, "/socket");
}

void draw() {
}

void mouseClicked() {  
  wss.sendMessage(outmsg);
}

void webSocketServerEvent(String msg) {
  println("event: "+msg);
}

```

```auto
// websockets
// https://github.com/alexandrainst/processing_websockets
// file websocket_client2.pde
// processing 3.5.3 on win7 / 64bit

import websockets.*;
String outmsg="Client mouse click";

String server = "ws://localhost:8025/socket"; 
// if i use my RPI as server: "ws://192.168.1.203:8025/socket"; // 
WebsocketClient wsc;

void setup() {
  size(500, 500);
  wsc= new WebsocketClient(this, server);
  println("pls wait for mouse click on server canvas");
}

void draw() {
}

void mouseClicked() {
  wsc.sendMessage(outmsg);
}

void webSocketEvent(String msg) {
  println("event: "+msg);
}

```

( means both sketch run on same computer )  
then the console print works / but might be little bit confusing regarding  
in what IDE window the print occurs.

---

<div class="post-metadata">

### Author: ![usufwasi](https://avatars.discourse-cdn.com/v4/letter/u/a4c791/32.png) [@usufwasi](https://discourse.processing.org/u/usufwasi)
#### Post date: [July 7, 2019, 12:13pm UTC](https://discourse.processing.org/t/error-in-websockets-library/12550/3 "2019-07-07T12:13:36Z")

</div>

Thank you for the reply. I found the solution. For some reason the program does not work if you copy/paste the example code from github. But, if I run it directly from the examples folder it works fine.
