If I understand your application correctly, you are opening and closing niSwitch session for every connect you want to make. Please try to limit opening and closing of a session to once per application. Doing so will save you significant amount of time as the initialization is not an inexpensive operation time-wise.
Another benefit from using a single session is that errors like the one you've got (invalid session) should be rare and far apart.
If what you're doing is a single open/close session, and you only loop on switch connects, then yes, you will have to perform a disconnect operation before trying to make the new connection between the same two channels.*
Hope this helps!
* this of course depends on the topology. In general, matrices will allow more than one connection to a row or a column (but still the endpoints must not be the same), while muxes will not. There are no implicit disconnects in a switch session.