# Understanding and Addressing the "Deflater Has Been Closed" Exception in Java WebSocket

**URL:** <https://community.openems.io/t/understanding-and-addressing-the-deflater-has-been-closed-exception-in-java-websocket/2624>\
**Category:** Uncategorized\
**Created:** [May 2, 2024, 9:55pm UTC](https://community.openems.io/t/understanding-and-addressing-the-deflater-has-been-closed-exception-in-java-websocket/2624 "2024-05-02T21:55:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sn0w3y](https://community.openems.io/user_avatar/community.openems.io/sn0w3y/32/636_2.png) [@Sn0w3y](https://community.openems.io/u/Sn0w3y)\
**Post date:** [May 2, 2024, 9:55pm UTC](https://community.openems.io/t/understanding-and-addressing-the-deflater-has-been-closed-exception-in-java-websocket/2624/1 "2024-05-02T21:55:02Z")

</div>

Hello everyone,

I’m reaching out for help regarding a recurring issue I’ve been facing with the OpenEMS WebSocket server. The error logs keep showing `NullPointerException` with the message “Deflater has been closed.” The error trace usually looks like this:

```auto
ERROR [socket.AbstractWebsocketServer] OnInternalError for EdgeWebsocket.WsData [edgeId=sems200]. java.lang.NullPointerException: Deflater has been closed
...
at java.util.zip.Deflater.ensureOpen(Deflater.java:898)
at java.util.zip.Deflater.deflate(Deflater.java:566)
at org.java_websocket.extensions.permessage_deflate.PerMessageDeflateExtension.encodeFrame(PerMessageDeflateExtension.java:227)
...

```

### The Problem

From what I understand, the error occurs when the Deflater is accessed after being closed. However, I’m unsure what exactly triggers this, and why it’s happening in the WebSocket server. Here are some scenarios I’ve observed:

- The error sometimes occurs when a client disconnects and attempts to reconnect.
- In some cases, it happens during high-load scenarios with multiple concurrent WebSocket connections.

@stefan.feilmeier @miettal just FYI

---

<div class="post-metadata">

**Author:** ![Sn0w3y](https://community.openems.io/user_avatar/community.openems.io/sn0w3y/32/636_2.png) [@Sn0w3y](https://community.openems.io/u/Sn0w3y)\
**Post date:** [May 4, 2024, 12:47pm UTC](https://community.openems.io/t/understanding-and-addressing-the-deflater-has-been-closed-exception-in-java-websocket/2624/2 "2024-05-04T12:47:35Z")

</div>

Found out, it happens ALL the time if you edit a something in the configuration in the WebUI.
