Skip to content

Conversation

@zensh
Copy link

@zensh zensh commented Oct 17, 2017

If socket was killed, it should be removed in session so that new socket can be setup for session.

@zensh zensh changed the title try to fix socket error for session try to fix socket error (i/o timeout) for session Oct 17, 2017
@zensh zensh changed the title try to fix socket error (i/o timeout) for session try to fix socket i/o error for session Oct 17, 2017
@zensh
Copy link
Author

zensh commented Oct 17, 2017

@niemeyer https://travis-ci.org/go-mgo/mgo/jobs/289072737 this job failed, it should be restart~

@zensh
Copy link
Author

zensh commented Oct 18, 2017

After this PR,we can use:

s := session.Clone()
defer s.Close()

instead of

s := session.Copy()
defer s.Close()

@zensh
Copy link
Author

zensh commented Oct 27, 2017

We can try the issue with code:

func main() {
	session, err := mgo.DialWithInfo(someRemoteDailInfo)
	if err != nil {
		panic(err)
	}

	for {
		fmt.Println("Ping:", session.Ping())
		time.Sleep(time.Second)
	}
}

Run it, then close the wifi, and then open the wifi, some result like this:

Ping: <nil>
Ping: <nil>
Ping: <nil>
Ping: <nil>
Ping: <nil>
Ping: <nil>
Ping: <nil>
Ping: read tcp 192.168.0.72:58883->192.168.0.21:27017: i/o timeout
Ping: no reachable servers
Ping: <nil>
Ping: <nil>
Ping: <nil>

It means that the session will reconnect automatic.

@zensh
Copy link
Author

zensh commented Nov 14, 2017

@niemeyer Could you review this PR? We have used the fork version in our productions

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

Successfully merging this pull request may close these issues.

1 participant