We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I've tried connection string (from Go) with nodejs and it works successfully (after escaping the password):
const {MongoClient} = require('mongodb'); (new MongoClient('mongodb://rwuser:1vK6c6%7Dc24Rr%28%2A%[email protected].:27017/mongodbtest1?connectTimeoutMS=1000&wtimeoutMS=1000')).connect()
but when I tried the exact connection string, which is generated from this code:
func (c ConnectOption) ToUrl() string { ms := timeout.Milliseconds() res := fmt.Sprintf("mongodb://%s:%s@%s/%s?connectTimeoutMS=%d&wtimeoutMS=%d", c.Username, url.QueryEscape(c.Password), c.Hosts, c.DBName, ms, ms) return res }
it shows exact same error error as when the password not escaped:
panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x80 pc=0x8dd963] goroutine 1 [running]: sync.(*RWMutex).RLock(...) /usr/local/go/src/sync/rwmutex.go:48 github.com/globalsign/mgo.(*Session).acquireSocket(0x0, 0x42ed01, 0x0, 0x0, 0x0) /go/pkg/mod/github.com/globalsign/[email protected]/session.go:5101 +0x53 github.com/globalsign/mgo.(*Database).Run(0xc00074d868, 0xb912c0, 0xc00072c4a0, 0xb866c0, 0xc00016a230, 0x0, 0x0) /go/pkg/mod/github.com/globalsign/[email protected]/session.go:992 +0x53 github.com/globalsign/mgo.(*Session).Run(0x0, 0xb912c0, 0xc00072c4a0, 0xb866c0, 0xc00016a230, 0xc0001965a0, 0xc00074d918) /go/pkg/mod/github.com/globalsign/[email protected]/session.go:2489 +0x8a github.com/globalsign/mgo.(*Session).BuildInfo(0x0, 0xb7, 0x0, 0xd95b40, 0xc0001965a0, 0x203000, 0x203000, 0x203000, 0x0, 0xc00074da80, ...) /go/pkg/mod/github.com/globalsign/[email protected]/session.go:5071 +0x101 gopkg.in/DataDog/dd-trace-go.v1/contrib/globalsign/mgo.Dial(0xc000758000, 0xb7, 0xc00074db18, 0x2, 0x2, 0xc00002634c, 0xd, 0xc0000262cc) /go/pkg/mod/gopkg.in/!data!dog/[email protected]/contrib/globalsign/mgo/mgo.go:25 +0x80 dummyproject/testmongo1/database/mongodb.Client(0xc00002205e, 0x39, 0xc00002a128, 0x22, 0x0, 0xc00002634c, 0xd, 0xc0000262cc, 0x14, 0xc00074dc00, ...) /go/src/dummyproject/testmongo1/database/mongodb/mongodb.go:67 +0x14c dummyproject/testmongo1/database/mongodb.DBFromEnv(0xc8050f) /go/src/dummyproject/testmongo1/database/mongodb/mongodb.go:155 +0x1dc dummyproject/testmongo1/database.InitDatabase() /go/src/dummyproject/testmongo1/database/database.go:15 +0xa4 dummyproject/testmongo1.Newtestmongo1(0xc00074ded8) /go/src/dummyproject/testmongo1/testmongo1.go:43 +0x177 main.main() /go/src/dummyproject/testmongo1/app/web/main.go:24 +0x8a
It runs on alpine docker, what's the other possible cause?
The lines testmongo1/database/mongodb/mongodb.go:67 are:
testmongo1/database/mongodb/mongodb.go:67
session, err := mgo.Dial(opt.ToUrl(timeout()), mgo.WithServiceName(`cinderella-mongo`), mgo.WithAnalytics(true))
mgo is a package, opt is not nil, timeout() returns concrete time.Duration, so there's no way that it's that line's that causes the error.
mgo
opt
timeout()
time.Duration
The text was updated successfully, but these errors were encountered:
Have you tried posting this issue on the globalsign/mgo repository? Based on the stack trace it seems like the problem is coming from there...
globalsign/mgo
Sorry, something went wrong.
@kokizzu
Based on your trace, I believe I see that we're calling BuildInfo on a nil mgo.(*Session) object on this line
BuildInfo
nil
mgo.(*Session)
It looks like we don't check the err return before using the *Session.
err
*Session
github.com/globalsign/mgo.(*Session).BuildInfo(0x0, 0xb7, 0x0, 0xd95b40, 0xc0001965a0, 0x203000, 0x203000, 0x203000, 0x0, 0xc00074da80, ...) /go/pkg/mod/github.com/globalsign/[email protected]/session.go:5071 +0x101
contrib/globalsign/mgo: check for error after dialing to avoid panic
705906c
Fixes #870
contrib/globalsign/mgo: check for error after dialing to avoid panic (#…
63dea35
…937) This commit fixes a bug causing a panic when mgo fails to dial the database. Fixes #870
Successfully merging a pull request may close this issue.
I've tried connection string (from Go) with nodejs and it works successfully (after escaping the password):
but when I tried the exact connection string, which is generated from this code:
it shows exact same error error as when the password not escaped:
It runs on alpine docker, what's the other possible cause?
The lines
testmongo1/database/mongodb/mongodb.go:67
are:mgo
is a package,opt
is not nil,timeout()
returns concretetime.Duration
, so there's no way that it's that line's that causes the error.The text was updated successfully, but these errors were encountered: