Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If windows VM network abrupts or resets, the winrm connection breaks and then does not reconnect #169

Open
rishabhkemni opened this issue Sep 19, 2024 · 0 comments

Comments

@rishabhkemni
Copy link

rishabhkemni commented Sep 19, 2024

Issue:
When trying to connect to a windows VM using a go program and fetching list of directories in loop for 5 times

If during this operation, windows VM network disconnects or network service restarts, the connection to windows VM breaks with following error:

Error while running command :unknown error Post "http://74.225.159.106:5985/wsman": net/http: timeout awaiting response headers

And then when retry is tried the connection fails with the following errors

:http response error: 401 - invalid content type

I already tried recreating endpoint and client object again during next retry once the connection fails during timeout but still same error occurs

endpoint config used:

winrm.NewEndpoint("", 5985, false, false, nil, nil, nil, 300)

winrm config:

Authentication used for winRM Client and Service: Basic
Allow unencrypted traffic: true

Code used:
// creating a new client object
client, err = winrm.NewClient(endpoint, username, password)

loop start
stdout, stderr, stdcode, err := client.RunWithString("dir", "")
if err != nil {
log.Println("Error creating connection and executing command: ", err)
if max retry done:
return err
else: continue
}
if stdcode != 0 {
log.Println("Error: encountered during executing command: ", err)
if max retry done:
return err
else: continue
} else {
return nil
}

return nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant