# Connect and Disconnect events not working on webSocketSever

**URL:** <https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252>\
**Category:** Libraries\
**Created:** [March 4, 2021, 10:44am UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252 "2021-03-04T10:44:03Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![yeppii](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yeppii/32/12180_2.png) [@yeppii](https://discourse.processing.org/u/yeppii)\
**Post date:** [March 4, 2021, 10:44am UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/1 "2021-03-04T10:44:03Z")

</div>

These two functions are not getting called by WebSocketServer. What to do to solve it? (I am using this library → [GitHub - alexandrainst/processing\_websockets: A web socket library, including both server and client, for Processing](https://github.com/alexandrainst/processing_websockets))

```java
    public void webSocketConnectEvent(String uid, String ip) {
        Logger.log(Logger.LogLevel.INFO, "Someone connected with UID " + uid + "and IP" + ip);
        connectedUsers++;
    }

    public void webSocketDisconnectEvent(String uid, String ip) {
        Logger.log(Logger.LogLevel.INFO, "Someone disconnected with UID " + uid + "and IP" + ip);
        connectedUsers--;
    }

```

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [March 4, 2021, 6:38pm UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/2 "2021-03-04T18:38:03Z")

</div>

It took me some time to figure this out this problem, but actually the downloadable library on Processing Contribution Manager is an old one. Try replacing it from the one from github (just download the zip, extract it and rename it as websockets)

---

<div class="post-metadata">

**Author:** ![yeppii](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yeppii/32/12180_2.png) [@yeppii](https://discourse.processing.org/u/yeppii)\
**Post date:** [March 6, 2021, 12:27pm UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/3 "2021-03-06T12:27:29Z")

</div>

okay i will try that.

---

<div class="post-metadata">

**Author:** ![yeppii](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yeppii/32/12180_2.png) [@yeppii](https://discourse.processing.org/u/yeppii)\
**Post date:** [March 6, 2021, 1:20pm UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/4 "2021-03-06T13:20:35Z")

</div>

i tried it but still its not working 😕

---

<div class="post-metadata">

**Author:** ![yeppii](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yeppii/32/12180_2.png) [@yeppii](https://discourse.processing.org/u/yeppii)\
**Post date:** [March 6, 2021, 1:21pm UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/5 "2021-03-06T13:21:52Z")

</div>

i did as you said. Downloaded the zip, extracted it, added the folder to the jar list in my intellij project, but still the problem didnt go

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [March 6, 2021, 1:42pm UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/6 "2021-03-06T13:42:22Z")

</div>

oh sorry to hear that. But _please_ be a bit more friendly even though english may not be your mother tongue - like saying “thank you” or “can you help me with…” - because this is not a product support forum but a place for community members to support each other 🙂

The solution worked in my case, and the only difference seems to be that I use Processing IDE and you are using IntelliJ. Can you check first with Processing IDE if the callbacks work for you? If it works, then there may be something wrong with the settings of IntelliJ. If it doesn’t work, it could be that you are still using an old version of the lib or you are not using the callback in the right way.

---

<div class="post-metadata">

**Author:** ![yeppii](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yeppii/32/12180_2.png) [@yeppii](https://discourse.processing.org/u/yeppii)\
**Post date:** [March 6, 2021, 3:05pm UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/7 "2021-03-06T15:05:42Z")

</div>

okay i will try it with processing ide.

---

<div class="post-metadata">

**Author:** ![yeppii](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yeppii/32/12180_2.png) [@yeppii](https://discourse.processing.org/u/yeppii)\
**Post date:** [March 6, 2021, 3:27pm UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/8 "2021-03-06T15:27:19Z")

</div>

I tried it on processing ide and it still doesnt work.

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [March 6, 2021, 7:52pm UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/9 "2021-03-06T19:52:02Z")

</div>

I don’t want to repeat it but as I wrote above please add a few more words to sound nicer. If it doesn’t work I don’t know what else to suggest. Maybe you can submit an issue on github if you think this is due to the library?

---

<div class="post-metadata">

**Author:** ![yeppii](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yeppii/32/12180_2.png) [@yeppii](https://discourse.processing.org/u/yeppii)\
**Post date:** [March 7, 2021, 10:26am UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/10 "2021-03-07T10:26:30Z")

</div>

okay! I will try opening an issue on the repository of the library! Can you suggest any other java WebSocket libraries that are easy to use?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [March 7, 2021, 11:44pm UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/11 "2021-03-07T23:44:14Z")

</div>

Hello @micuat,

Confirming that connect\disconnect events (as per code on website below) worked fine here once I had the latest updates from here:

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

And this Download ZIP:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/dffb3650a02c6d1128967b3286478421938087f1.png)

`:)`

---

<div class="post-metadata">

**Author:** ![yeppii](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yeppii/32/12180_2.png) [@yeppii](https://discourse.processing.org/u/yeppii)\
**Post date:** [March 8, 2021, 5:57am UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/12 "2021-03-08T05:57:51Z")

</div>

did the disconnect and connect events trigger correctly?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [March 10, 2021, 11:43am UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/13 "2021-03-10T11:43:59Z")

</div>

> [@yeppii](#):
>
> did the disconnect and connect events trigger correctly?

Yes.

There appears to be a ticket for this but it lacks details:

> <https://github.com/alexandrainst/processing_websockets/issues/22>
>
> The \`public void webSocketDisconnectEvent(String uid, String ip)\` event and \`pub…lic void webSocketConnectEvent(String uid, String ip)\` event doesnt work. I downloaded the JAR from releases.

---

<div class="post-metadata">

**Author:** ![yeppii](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yeppii/32/12180_2.png) [@yeppii](https://discourse.processing.org/u/yeppii)\
**Post date:** [March 11, 2021, 10:13am UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/14 "2021-03-11T10:13:51Z")

</div>

Should I compile the jar from the source and use that jar?

---

<div class="post-metadata">

**Author:** ![yeppii](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yeppii/32/12180_2.png) [@yeppii](https://discourse.processing.org/u/yeppii)\
**Post date:** [March 11, 2021, 10:14am UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/15 "2021-03-11T10:14:57Z")

</div>

I opened that issue.

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [March 11, 2021, 11:22am UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/16 "2021-03-11T11:22:32Z")

</div>

I don’t think so, I tried the compiled jar from github and it worked on the IDE as I wrote above. I guess you have issues with installing the library and perhaps your code is still loading the old one. You tested both on IntelliJ and processing IDE with the latest repo and neither worked, right?

---

<div class="post-metadata">

**Author:** ![yeppii](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yeppii/32/12180_2.png) [@yeppii](https://discourse.processing.org/u/yeppii)\
**Post date:** [March 11, 2021, 12:55pm UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/17 "2021-03-11T12:55:42Z")

</div>

yes, I tried on both IntelliJ and processing ide and the library doesn’t seem to work

---

<div class="post-metadata">

**Author:** ![yeppii](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yeppii/32/12180_2.png) [@yeppii](https://discourse.processing.org/u/yeppii)\
**Post date:** [March 11, 2021, 1:08pm UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/18 "2021-03-11T13:08:32Z")

</div>

downloaded this [processing\_websockets/webSockets.zip at master · alexandrainst/processing\_websockets · GitHub](https://github.com/alexandrainst/processing_websockets/blob/master/webSockets.zip) and it worked!

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [March 13, 2021, 12:25pm UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/19 "2021-03-13T12:25:00Z")

</div>

> [@yeppii](#):
>
> I opened that issue.

Hello,

Since you got this to work can you please update the GitHib issue that you opened:

_[Connect and disconnect events doesn't work. · Issue #22 · alexandrainst/processing\_websockets · GitHub](https://github.com/alexandrainst/processing_websockets/issues/22)_

`:)`

---

<div class="post-metadata">

**Author:** ![yeppii](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yeppii/32/12180_2.png) [@yeppii](https://discourse.processing.org/u/yeppii)\
**Post date:** [March 13, 2021, 2:22pm UTC](https://discourse.processing.org/t/connect-and-disconnect-events-not-working-on-websocketsever/28252/20 "2021-03-13T14:22:13Z")

</div>

Issue closed! Now my issue is solved and I can continue making the server for my game!
