VixDiskLib_ConnectEx() connects the library to managed disk on a remote ESXi host or through VMware vCenter Server. For hosted disk on the local system, it works the same as VixDiskLib_Connect(). VixDiskLib_ConnectEx() takes three additional parameters:
When a program calls VixDiskLib_ConnectEx() with NULL parameter to accept default transport mode, SAN is selected as the preferred mode, if SAN storage is available from the ESXi host. Then if the program opens a virtual disk on local storage, subsequent writes will fail. In this case, the program should explicitly pass nbdssl as the preferred transport mode.
The port is where vCenter Server listens for API queries. Specifying null allows the library to select the port, usually 443 (HTTPS). By default VADP uses the same port for virtual machine operations as other SOAP-based Web Services. By default VDDK uses port 902 (VIX automation) for NBDSSL data transport.
In the connection parameters cnxParams, the vmxSpec managed object reference would be different on an ESXi host than on the vCenter Server, as shown below. ESXi hosts offer no prepare-for and end access protection. Otherwise ESXi host connections are similar to vCenter Server connections.
vmxSpec = "moid=23498"; vmxSpec = "moid=898273";
As of vSphere 6.5, you can recycle a vCenter Server session to avoid connection overflow. Set the credential type to VIXDISKLIB_CRED_SESSIONID and supply the value of vmware_soap_session from a still-live vCenter Server session.
if (appGlobals.isRemote) { cnxParams.vmName = vmxSpec; cnxParams.serverName = hostName; cnxParams.credType = VIXDISKLIB_CRED_SESSIONID; cnxParams.creds.sessionId.cookie = cookie; cnxParams.creds.sessionId.userName = userName; cnxParams.creds.sessionId.key = password; cnxParams.port = port; }