code: function reliablySendPreparedMessageToHub(ws, recipient_device_pubkey, json, callbacks, conn){
  	var recipient_device_address = objectHash.getDeviceAddress(recipient_device_pubkey);
  	console.log('will encrypt and send to '+recipient_device_address+': '+JSON.stringify(json));
  	// encrypt to recipient's permanent pubkey before storing the message into outbox
  	var objEncryptedPackage = createEncryptedPackage(json, recipient_device_pubkey);
  	// if the first attempt fails, this will be the inner message
  	var objDeviceMessage = {
  		encrypted_package: objEncryptedPackage
  	};
  	var message_hash = objectHash.getBase64Hash(objDeviceMessage);
  	conn = conn || db;
  	conn.query(
  		"INSERT INTO outbox (message_hash, `to`, message) VALUES (?,?,?)", 
  		[message_hash, recipient_device_address, JSON.stringify(objDeviceMessage)], 
  		function(){
  			if (callbacks && callbacks.onSaved)
  				callbacks.onSaved();
  			sendPreparedMessageToHub(ws, recipient_device_pubkey, message_hash, json, callbacks);
  		}
  	);
  }
docs: reliable delivery first param is either WebSocket or hostname of the hub