thomasp85 / fiery

A flexible and lightweight web server
https://fiery.data-imaginist.com
Other
244 stars 12 forks source link

Error in attributes(.Data)... on linux ubuntu #16

Closed ZJUguquan closed 7 years ago

ZJUguquan commented 7 years ago

Hi, @thomasp85 I've run your example code on both Windows 10(my own PC) and Linux Ubuntu(on the server). When on Windows, it runs OK, but when on Ubuntu, it comes with "Error in attributes(.Data)... "

My Ubuntu environment is below,

> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.0
LAPACK: /usr/lib/lapack/liblapack.so.3.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] fiery_1.0.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.12     codetools_0.2-15 brotli_1.0       listenv_0.6.0
 [5] future_1.6.0     digest_0.6.12    later_0.3        assertthat_0.2.0
 [9] R6_2.2.2         jsonlite_1.5     stringi_1.1.5    uuid_0.1-2
[13] xml2_1.1.1       webutils_0.6     urltools_1.6.0   reqres_0.2.0
[17] tools_3.4.0      triebeard_0.3.0  httpuv_1.3.3     parallel_3.4.0
[21] compiler_3.4.0   globals_0.10.2

And my code is just yours, (some rows deleted)

> library(fiery)
> 
> app <- Fire$new()
> app$host <- '192.168.1.22'  #This is the host of server
> app$port <- 19177
> 
> # Setup the data every time it starts
> app$on('start', function(server, ...) {
+   server$set_data('visits', 0)
+   server$set_data('cycles', 0)
+ })
> 
> # Count the number of cycles (internal loops)
> app$on('cycle-start', function(server, ...) {
+   server$set_data('cycles', server$get_data('cycles') + 1)
+ })
> 
> # Count the number of requests
> app$on('before-request', function(server, ...) {
+   server$set_data('visits', server$get_data('visits') + 1)
+ })
> 
> # Handle requests
> app$on('request', function(server, request, ...) {
+   response <- request$respond()
+   response$status <- 200L
+   response$body <- paste0('<h1>This is indeed a test. You are number ', server$get_data('visits'), '</h1>')
+   response$type <- 'html'
+ })
> 
> # Show number of requests in the console
> app$on('after-request', function(server, ...) {
+   message(server$get_data('visits'))
+   flush.console()
+ })
> 
> 
> # Be polite
> app$on('end', function(server) {
+   message('Goodbye')
+   flush.console()
+ })
> 
> app$ignite(showcase = TRUE)
Fire started at 192.168.1.22:19177
Error in attributes(.Data) <- c(attributes(.Data), attrib) : 
  'names' attribute [8] must be the same length as the vector [7]
ERROR: [on_request_read] parse error
Error in attributes(.Data) <- c(attributes(.Data), attrib) : 
  'names' attribute [8] must be the same length as the vector [7]
ERROR: [on_request_read] parse error

The same code I run on Windows do not come with any error (the host I set is '127.0.0.1'). However, when on Windows, I couldn't let other people in the local area network(LAN) visit my app whatever host I set(e.g. app$host <- '0.0.0.0' or app$host <- '127.0.0.1' or app$host <- '192.168.1.144'(my IPv4 address on Windows))

So, there are 2 questions I want to consult, 1, how to solve the Ubuntu 'Error in attributes(.Data)...'? 2, how to set the host address to let others visit my app if I use Windows 10?

Waiting for your reply~ Thank you~

thomasp85 commented 7 years ago

Hmm... I cannot reproduce your error on our Ubuntu system, so I suspect it's local. Do you get it if you set (showcase = FALSE)

As for 2, I suspect this is a firewall problem and not really related to fiery - 0.0.0.0 should allow others to access your server...

ZJUguquan commented 7 years ago

@thomasp85, thanks for your kind reply.

I'm sorry, for question 2, actually setting app$host <- '0.0.0.0' works well.

For question 1, I still get the same error on node of 192.168.1.22... >_<! And my traceback is

...
> app$ignite(showcase = F)
Fire started at 192.168.1.22:19177
Error in attributes(.Data) <- c(attributes(.Data), attrib) :
  'names' attribute [8] must be the same length as the vector [7]
ERROR: [on_request_read] parse error

> traceback()
4: Sys.sleep(self$refresh_rate)
3: private$run_blocking_server(showcase = showcase)
2: private$run(block = block, showcase = showcase, ...)
1: app$ignite(showcase = F)

I should have tested the code on other server nodes before submitting issues... sorry... Under the same Ubuntu cluster on 192.168.1.25, it goes with no problems...

Thanks again !!

thomasp85 commented 7 years ago

Happy one problem is solved. Have you run update.packages() (though this is a shot in the dark)

thomasp85 commented 7 years ago

Did you close it because you got it fixed?