Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket is not defined #23

Open
phil-flip opened this issue Jun 8, 2021 · 3 comments
Open

WebSocket is not defined #23

phil-flip opened this issue Jun 8, 2021 · 3 comments

Comments

@phil-flip
Copy link

Hello, I am really interested in using this dependency, but sadly can't get it to work in my node.js project with the adjusted sample code.
If I try to run it, I receive this error, even tho I have WS installed as well. Can you help me out with this?
(node:18596) UnhandledPromiseRejectionWarning: ReferenceError: WebSocket is not defined

@houd1ni
Copy link
Owner

houd1ni commented Jul 16, 2021

Hi! Dangit - github sends tons of sh*t as notifications. 😭 Now disabling them explicitly.

There's adapter field in config to attach ws package into there because Node has not WebSocket native implementation.

afaik, it shoud work:

import WSP from 'wspromisify'
import WebSocket from 'ws'

const wsp = new WSP({
  adapter: ((host, protocols) => new WebSocket(host, protocols))
})

In README it is:

  • Supports middleware-adapter. E.g. you can use 'ws' package in Node!

I've created issue to make recipes. Thanks!

@phil-flip
Copy link
Author

Heyo, while haven't implemented it after all, ill look into changing the code. But I need to do some speed-tests first, as there are multiple sends and requests in under a second in the Project I'm working on

@houd1ni
Copy link
Owner

houd1ni commented Feb 28, 2023

This will be updated after #37 is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants