-
Notifications
You must be signed in to change notification settings - Fork 96
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
Connection Reset by Peer if Application is Idle For Too Long #68
Comments
conn, err := net.Dial("tcp", server)
if err != nil {
log.Fatal(err)
}
defer conn.Close()
conn.SetDeadline(time.Time{}) // this did not resolve the issue
d := &smb2.Dialer{
Initiator: &smb2.NTLMInitiator{
User: settings.Username,
Password: settings.Password,
},
}
s, err := d.Dial(conn)
if err != nil {
log.Fatal(err)
}
defer s.Logoff()
share, err := s.Mount("C")
if err != nil {
log.Fatal(err)
}
defer share.Umount()
go func() {
for {
select {
[...] // application will hang here until local changes are made
}
}
}() |
implement a redial |
you can use |
the timeout is the problem, not what he wants. What he wants is a "keep alive" for the connection. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, I wrote a file sync application to sync changes in a local repository to a remote SMB share. Everything is working perfectly so far, except when the program is idle for too long. Seems to take maybe 10-15 minutes. Data is not being sent all the time, I have a select statement that waits on a message from a channel about local changes. Then, depending on the type of change, it applies those changes to the share. Users can sometimes go a little while between saves, so the application will be idle for too long and the connection will reset. They then have to restart the application. I couldn't find anything about a timeout or something similar in the code, and setting a deadline of 0 on the
conn.Conn
type did nothing. Is something that I would be able to fix, or is this an issue with SMB, or my SMB server specifically?Error message with some information redacted:
The only workaround I can think of is to have a goroutine stat a file every few minutes, but that doesn't feel right.
The text was updated successfully, but these errors were encountered: