VMware Cloud Community
DroppedAtBirth
Contributor
Contributor
Jump to solution

Disconnect issues

Trying to figure out if a disconnect problem that has come up is a .net issue, programming issue, powershell issue, or a VI Toolkit issue.

Basically we have a .net service with 2 threads. ThreadOne is running reports, getting data, etc.. over and over(could take 1 sec or 10 minutes per script). ThreadTwo creates VM when we tell it to, so it occasionally has work.

ThreadOne - looping over task it does - never ending loop of work

Connect-VIServer

DoSomeThing() - could take 1 sec or 10 minutes...

DisConnect-VIServer

ThreadTwo

Connect-VIServer

CREATEVM()

DisConnect-VIServer

Now the problem, we originally didn't have DisConnect-VIServer after each script and we max out sessions. Whoops... Bad thing, bad programming. Fixed by adding disconnect after each script, session problem went away. Now we found a huge problem with this solution, that we can't seem to fix.

What appears to be happening is ThreadTwo starts, which is for creating a VM, it executes a long script that creates a VM using sysprep and alot of options and waits the VM to be created, watching the task. All this while ThreadOne is running over and over (connecting and disconnecting each time). It appears once ThreadOne calls DisConnect-VIServer, it disconnects ThreadTwo also, because we get a "not connected" error at random spots in createvm script, sometimes it gets to starting the create vm task(if it does the task completes without problem, but our services thinks it failed), sometimes get disconnected before the task gets started. If we disable Threadone, ThreadTwo appears to working fine. So this issues appears to have been created when we added the Disconnect-viserver calls.

Ok, now for more details on how we are calling the scripts. Scripts are calls via a VB.net Windows Service. Here is the Basic Flow of each script call.

1. Create .net runspace with vim.psc1 config

2. Create .net pipeline

3. call pipeline.invoke() only passing in connection string "Connect-VIServer ....."

4. check for errors...

5. re-dim .net pipeline

6. call pipeline.invoke() passing in whatever script needs to be run(report, create-vm, etc...)

NOTE: DisConnect-VIServer is appending to the end of the script

7. Close and Destroy .net runspace

8. Results are returned, datatable

0 Kudos
1 Solution

Accepted Solutions
admin
Immortal
Immortal
Jump to solution

The problem is that Disconnect-VIServer is trying to update the console window by writing to a variable -- I forget which one but maybe someone on the dev team will chime in.

I posted a workaround in your other thread.

We're tracking this as a bug.

View solution in original post

0 Kudos
2 Replies
admin
Immortal
Immortal
Jump to solution

The problem is that Disconnect-VIServer is trying to update the console window by writing to a variable -- I forget which one but maybe someone on the dev team will chime in.

I posted a workaround in your other thread.

We're tracking this as a bug.

0 Kudos
DroppedAtBirth
Contributor
Contributor
Jump to solution

Thanks Again c_shanklin, the solution(s) on My 1.5 Upgrade Issues Post work great.

0 Kudos