Canceled DO WebSocket Connection

Good Day!
Transitioning our fully functional WebSockets to DO w/ hibernation.
Problem: the DO and client now never make the connection.


Controller

export const AucWSDOHandler: Handler<Environment> = async (c) => {
  const env = c.env
  const request = c.req.raw
  const paramsParse = c.req.param()
  const params = lotValidation.getTuuid.parse(paramsParse)
  const path = params.tuuid
  
  const upgradeHeader = request.headers.get('Upgrade')
    if (!upgradeHeader || upgradeHeader !== 'websocket') {
        return new Response('Durable Object expected Upgrade: websocket', { status: 426 })
    }

  const id = env.AUCTIONDO.idFromName(path)
  const AuctionDO = env.AUCTIONDO.get(id)

  return AuctionDO.fetch(request)
}


It looks like the return of the request isn’t either sent, as the status on the front end only goes from Closed to Connecting back to Closed, or it’s not accepted or rejected by the client?

Because webSocketClose is triggered, the CF documentation says “the client closes the connection” then “runtime will invoke the webSocketClose() handler, is the client rejecting or resting the connection?


  • Service side the routing is handled by Hono, but WebSockets work fine outside DOs and can see with logs the request is making it to the DO.
  • On the client side we are using react-use-websocket ?? Can’t find anything that WebSockets with DOs should be handled any differently..
Ideas if the issue is backend or frontend? Or how to narrow down where the problem is.
Something glaringly wrong (embarrassing 🤭 ) with what we’ve setup?
Was this page helpful?