Check whether req.res is null before sending error code. This occurs when the websocket transport is not supported.