# Using Websocket with ble gateway v4

**URL:** <https://bbs.aprbrother.com/t/using-websocket-with-ble-gateway-v4/1866>\
**Category:** BLE Gateway\
**Created:** [September 1, 2022, 7:57pm UTC](https://bbs.aprbrother.com/t/using-websocket-with-ble-gateway-v4/1866 "2022-09-01T19:57:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dany\_magadan](https://bbs.aprbrother.com/letter_avatar_proxy/v4/letter/d/47e85d/32.png) [@dany\_magadan](https://bbs.aprbrother.com/u/dany_magadan)\
**Post date:** [September 1, 2022, 7:57pm UTC](https://bbs.aprbrother.com/t/using-websocket-with-ble-gateway-v4/1866/1 "2022-09-01T19:57:06Z")

</div>

Hi, I am using ble gateway v4,  
and I get everything through the httpserver example,  
is there an example using sockets?  
I can’t understand how to hear the word data and end in the sockets.

 ![image](https://bbs.aprbrother.com/uploads/default/original/1X/22bed5fe054c40382734ca76e538cfe3d5ea7645.png)

---

<div class="post-metadata">

**Author:** ![aprilpea](https://bbs.aprbrother.com/user_avatar/bbs.aprbrother.com/aprilpea/32/9_2.png) [@aprilpea](https://bbs.aprbrother.com/u/aprilpea)\
**Post date:** [September 2, 2022, 2:15am UTC](https://bbs.aprbrother.com/t/using-websocket-with-ble-gateway-v4/1866/2 "2022-09-02T02:15:04Z")

</div>

Did you configure the `Request Format` to `JSON`? Your code try to parse the data in JSON format.

Do you use the ws library for nodeJS? Show me the code how you start the WebSocket Server.

example:

```auto
import WebSocket, { WebSocketServer } from 'ws';

const wss = new WebSocketServer({
  port: 8080,
  perMessageDeflate: {
    zlibDeflateOptions: {
      // See zlib defaults.
      chunkSize: 1024,
      memLevel: 7,
      level: 3
    },
    zlibInflateOptions: {
      chunkSize: 10 * 1024
    },
    // Other options settable:
    clientNoContextTakeover: true, // Defaults to negotiated value.
    serverNoContextTakeover: true, // Defaults to negotiated value.
    serverMaxWindowBits: 10, // Defaults to negotiated value.
    // Below options specified as default values.
    concurrencyLimit: 10, // Limits zlib concurrency for perf.
    threshold: 1024 // Size (in bytes) below which messages
    // should not be compressed if context takeover is disabled.
  }
});

```
