Skip to content

Cannot Connect to WebSocket via Http/2 #5681

Description

@adiwajshing

Bug Description

On some domains, over TLS, http/2 web socket connects fail without a good explanation. Consistently reproducing w the domain in the example.

Reproduction

Standalone reproduction script:

import { Agent, WebSocket } from 'undici'
// turning this flag off, prints success
const dispatcher = new Agent({ allowH2: true })

const url = 'wss://web.whatsapp.com/ws/chat'
const ws = new WebSocket(url, { dispatcher })

ws.onopen = () => {
	console.log('Success!')
	ws.close()
}

ws.onerror = (err) => {
	console.log('error', err)
}

ws.onclose = ev => {
	console.log('close code', ev.code)
}

Steps to reproduce (if not using the script above):

Run the script above.

Expected Behavior

Successful connect

Actual Behavior

Disconnects w 1006

Environment

  • OS: MacOS 26
  • Node.js version: 26.1.0
  • undici version: 8.x.x

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions