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

How to handle WebSockets? #548

Closed
omar2205 opened this issue Mar 26, 2023 · 1 comment
Closed

How to handle WebSockets? #548

omar2205 opened this issue Mar 26, 2023 · 1 comment

Comments

@omar2205
Copy link

I have this endpoint:

// routes/h.ts
export function GET(req: Request) {
  const { socket, response } = Deno.upgradeWebSocket(req)

  socket.onopen = () => {
    console.log('WS OPEN')
    socket.send('Hello')
  }

  socket.onmessage = (e) => {
    console.log('msg', e.data)
    socket.send(new Date().toJSON())
  }

  return response
}

When I try to call this, like: let ws = new WebSocket('ws://localhost:8000/h'), I don't receive anything, and no 'WS OPEN' gets logged.

@ije
Copy link
Member

ije commented Mar 26, 2023

there is a bug about it, I will fix it ASAP

@ije ije closed this as completed in 57b811d Mar 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants