[GODRIVER-674] server selection timeout error when connecting to replica set Created: 05/Dec/18 Updated: 03/Apr/23 Resolved: 26/Dec/18 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | Connections |
| Affects Version/s: | 0.0.18 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | 성욱 조 | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
2 mongodb with docker (replica set configured successfully, shell connection works fine) |
||
| Description |
but result is: panic: server selection timeout |
| Comments |
| Comment by Jeffrey Yemin [ 26/Dec/18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Yes, it's expected. The application has to be able to connect to the hostname/port as contained in the replica set configuration. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by 성욱 조 [ 12/Dec/18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I checked the test program in the docker network and it works! I really appreciate it BUT I thought I can connect with docker-published ports. I run 3 nodes at docker. And I published each node's port to 27017, 27018, 27019. In this case, server selection timeout is normal? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Kristofer Brandow (Inactive) [ 11/Dec/18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi ghatdev, It looks like the replica set are on the host mongo-node* domains while you're attempting to connect over localhost. Can you use the host name that the }}{{rs.status is reporting? --Kris | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by 성욱 조 [ 11/Dec/18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@Kris Brandow I added third node and tested again but still server selection timeout error occurrences. This is my rs.status() output:
And this is my code.
Thanks! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Kristofer Brandow (Inactive) [ 10/Dec/18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi ghatdev, You must run at least 3 nodes in a replica set for an election to happen. Since you only have 2 nodes, neither of them can be elected primary and the driver only has secondaries to choose from. Can you configure the replica set with 3 nodes and try again? Thanks, Kris | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by 성욱 조 [ 05/Dec/18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
correction: go version is 1.11.1 (not 1.11.2) sorry |