# WebSocket client in Activity

**URL:** <https://community.temporal.io/t/websocket-client-in-activity/13313>\
**Category:** Community Support\
**Tags:** typescript-sdk\
**Created:** [August 27, 2024, 5:03pm UTC](https://community.temporal.io/t/websocket-client-in-activity/13313 "2024-08-27T17:03:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jelling](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/jelling/32/5043_2.png) [@jelling](https://community.temporal.io/u/jelling)\
**Post date:** [August 27, 2024, 5:03pm UTC](https://community.temporal.io/t/websocket-client-in-activity/13313/1 "2024-08-27T17:03:03Z")

</div>

Is there an example / is it possible to use a Websocket client inside of an activity using the typescript SDK?

The below code compiles when not being loaded as an activity by the worker. But I get ` Property 'dispatchEvent' is missing in type import` when Webpack tries to compile it for the bundle.

```auto
lib/service/comfy/src/server/client.ts(16,5): error TS2322: Type 'typeof WebSocket' is not assignable to type '{ new (url: string | URL, protocols?: string | string[] | undefined): WebSocket; prototype: WebSocket; readonly CONNECTING: 0; readonly OPEN: 1; readonly CLOSING: 2; readonly CLOSED: 3; }'.
  Types of property 'prototype' are incompatible.
    Property 'dispatchEvent' is missing in type 'import("/Users/jelling/dev/rbt/rbt-nx/node_modules/.pnpm/@types+ws@8.5.10/node_modules/@types/ws/index")' but required in type 'WebSocket'.

    at createTSError (/Users/jelling/dev/rbt/rbt-nx/node_modules/.pnpm/ts-node@10.9.2_@swc+core@1.3.107_@types+node@18.19.14_typescript@5.4.5/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/Users/jelling/dev/rbt/rbt-nx/node_modules/.pnpm/ts-node@10.9.2_@swc+core@1.3.107_@types+node@18.19.14_typescript@5.4.5/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/Users/jelling/dev/rbt/rbt-nx/node_modules/.pnpm/ts-node@10.9.2_@swc+core@1.3.107_@types+node@18.19.14_typescript@5.4.5/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/Users/jelling/dev/rbt/rbt-nx/node_modules/.pnpm/ts-node@10.9.2_@swc+core@1.3.107_@types+node@18.19.14_typescript@5.4.5/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/Users/jelling/dev/rbt/rbt-nx/node_modules/.pnpm/ts-node@10.9.2_@swc+core@1.3.107_@types+node@18.19.14_typescript@5.4.5/node_modules/ts-node/src/index.ts:1617:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at require.extensions.<computed> (/Users/jelling/dev/rbt/rbt-nx/node_modules/.pnpm/ts-node@10.9.2_@swc+core@1.3.107_@types+node@18.19.14_typescript@5.4.5/node_modules/ts-node/src/index.ts:1621:12)
    at Object.newLoader [as .ts] (/Users/jelling/dev/rbt/rbt-nx/node_modules/.pnpm/pirates@4.0.6/node_modules/pirates/lib/index.js:121:7)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Function.Module._load (node:internal/modules/cjs/loader:960:12) {
  diagnosticCodes: [2322]
}

```
