The IFrame and Websocket connection will both be based on the same Nonce. So, you will need to have the Nonce generated first.
After you have established a connection to the WebSocket, you will need to Register the Nonce.
ws.onopen = function() {
var obj = {
"action":"REGISTER",
"nonce":nonce
};
ws.send(JSON.stringify(obj));
};