jeroen / mongolite

Fast and Simple MongoDB Client for R
https://jeroen.github.io/mongolite/
287 stars 65 forks source link

Unable to connect remote mongoDB server from my Rstudio. #168

Open mallick84 opened 5 years ago

mallick84 commented 5 years ago

Hi Jeroen, I am very new to your package 'rmongolite'. I have your development version of rmongolite library package. devtools::install_github("jeroen/mongolite")

My desktop is connecting in LAN. I am running Rstudio in windows 10.

> sessionInfo() R version 3.5.1 (2018-07-02) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)  Matrix products: default  locale: [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                           [5] LC_TIME=English_United States.1252      attached base packages: [1] stats     graphics  grDevices utils     datasets  methods   base       other attached packages:  [1] rmongodb_1.8.0       mongolite_2.0        reshape2_1.4.3       plyr_1.8.4            [5] data.table_1.11.8    vars_1.5-3           lmtest_0.9-36        urca_1.3-0            [9] strucchange_1.5-1    sandwich_2.5-0       MASS_7.3-50          rJava_0.9-10         [13] DBI_1.0.0            odbc_1.1.6           lubridate_1.7.4      dplyr_0.7.8          [17] tidyr_0.8.2          highcharter_0.6.0    readr_1.1.1          xts_0.11-2           [21] zoo_1.8-4            tseries_0.10-45      ggfortify_0.4.5      forecast_8.4         [25] plotly_4.8.0         ggplot2_3.1.0        dbplyr_1.2.2         DT_0.5.1             [29] shinydashboard_0.7.1 shinyjs_1.0          shiny_1.2.0           loaded via a namespace (and not attached):  [1] httr_1.3.1        bit64_0.9-7       jsonlite_1.6      viridisLite_0.3.0  [5] uroot_2.0-9       assertthat_0.2.0  TTR_0.23-4        blob_1.1.1         [9] yaml_2.2.0        pillar_1.3.0      backports_1.1.2   lattice_0.20-35   [13] glue_1.3.0        rlist_0.4.6.1     quadprog_1.5-5    digest_0.6.18     [17] promises_1.0.1    colorspace_1.3-2  htmltools_0.3.6   httpuv_1.4.5      [21] timeDate_3043.102 pkgconfig_2.0.2   broom_0.5.1       purrr_0.2.5       [25] xtable_1.8-3      scales_1.0.0      whisker_0.3-2     later_0.7.5       [29] openssl_1.1       tibble_1.4.2      generics_0.0.2    withr_2.1.2       [33] nnet_7.3-12       lazyeval_0.2.1    quantmod_0.4-13   magrittr_1.5      [37] crayon_1.3.4      mime_0.6          nlme_3.1-137      tools_3.5.1       [41] hms_0.4.2         stringr_1.3.1     munsell_0.5.0     bindrcpp_0.2.2    [45] compiler_3.5.1    rlang_0.3.0.1     grid_3.5.1        rstudioapi_0.8    [49] htmlwidgets_1.3   igraph_1.2.2      gtable_0.2.0      fracdiff_1.4-2    [53] curl_3.2          R6_2.3.0          gridExtra_2.3     bit_1.1-14        [57] bindr_0.1.1       stringi_1.2.4     parallel_3.5.1    Rcpp_1.0.0        [61] tidyselect_0.2.5
--
 
> | >
>

As back end I have also installed mongoDB and here is nodejs app
> C:\Users\95000405>mongo
> MongoDB shell version v4.0.5
> connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
> Implicit session: session { "id" : UUID("d7c60096-f9e8-43ed-a1a8-afe06817f1b5") }
> MongoDB server version: 4.0.5
> Server has startup warnings:
> 2018-12-26T14:00:22.972+0530 I CONTROL  [initandlisten]
> 2018-12-26T14:00:22.980+0530 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
> 2018-12-26T14:00:22.981+0530 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
> 2018-12-26T14:00:22.981+0530 I CONTROL  [initandlisten]
> ---
> Enable MongoDB's free cloud-based monitoring service, which will then receive and display
> metrics about your deployment (disk utilization, CPU, operation statistics, etc).
> 
> The monitoring data will be available on a MongoDB website with a unique URL accessible to you
> and anyone you share the URL with. MongoDB may use this information to make product
> improvements and to suggest MongoDB products and deployment options to you.
> 
> To enable free monitoring, run the following command: db.enableFreeMonitoring()
> To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
> ---

I got authentication and host ip address of mongoDB server from our IT department as

Server URL : mongodb://10.4.27.104:27017 Auth. Credentials : Username : pass123

Database : SASANPI Collection : TAGVALUES

While connecting the mongoDB from R I get following error

> library(mongolite) 
> con<-mongo(collection = 'TAGVALUES',  
+             url = "mongodb://Username:pass123@10.4.27.104:27017/SASANPI")
 Error: No suitable servers found (`serverSelectionTryOnce` set): [connection timeout calling ismaster on '10.4.27.104:27017']
--
 
> | >
>

OR

> newdb <- mongo(collection= "TAGVALUES",  
+                db = "SASANPI", 
+                url = "mongodb://Username:pass123@10.4.27.104:27017/SASANPI", 
+                verbose = TRUE) 
Error: No suitable servers found (`serverSelectionTryOnce` set): [connection timeout calling ismaster on '10.4.27.104:27017']
--
 
> | >
>

while in nodejs app

> db.runCommand({"isMaster": 1})
{
        "ismaster" : true,
        "maxBsonObjectSize" : 16777216,
        "maxMessageSizeBytes" : 48000000,
        "maxWriteBatchSize" : 100000,
        "localTime" : ISODate("2018-12-27T06:16:03.425Z"),
        "logicalSessionTimeoutMinutes" : 30,
        "minWireVersion" : 0,
        "maxWireVersion" : 7,
        "readOnly" : false,
        "ok" : 1
}
> mongo mongodb://Username:pass123@10.4.27.104:27017/SASANPI
...

I have seen the discussion: 1 and 12

Can you help me to find out the exact related issue? Is it really the issue related to server end or from my end?