You cannot pass the token over the websocket in this way.
The line:
const ws = new WebSocket("/ws", pageToken);
Is specifically failing. Replace it with:
const ws = new WebSocket("/ws");
And it will connect.