crash Rstudio in AWS (linux based) after using a function

I developed my R code on my local computer. In my code, I mainly use swmmr package to run SWMM (stormwater management model) and further analysis related to the model outputs. To do that, I have used multiple packages (dplyr, shiny, leaflet, xts, zoo, ...). Everything is fine when I use my local computer and I can run my code from first to last and it works properly.

Now, I decided to move all my codes to AWS EC2 cloud. Because I need to run my code every one hour. I had some difficulties with this transformation, but I could solve most of them.

However, somewhere in my code, when I use the read_out() function from swmmr package, I get some warnings about masking some functions from other packages (attached figure) and my studio in AWS server crash.

Why does RStudio in AWS crash when I use this function? All other functions in this package works for me, just this function which I really need to use is not working and making the crash in Rstudio. As I said, it works properly in Rstudio on my local computer.
Any idea about fixing this problem would be appreciated.

Hi, welcome!

We don't really have enough info to help you out. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

If you've never heard of a reprex before, you might want to start by reading this FAQ:

Also, please notice that RStudio server running on AWS is not the same as RStudio Cloud which is a cloud service offered by RSTUDIO, not by AWS

Thank you for your replay.
So if you wanna replicate my work, you can download the .out file from this link:
https://github.com/HamedGhodsi90/CSO_Real-Time_Prediction/blob/master/SWMM_online.out

Then, use this code:

#install.packages("swmmr")
library(swmmr)
results <- read_out(file = "C:/ThePathToFile/SWMM_online.out", iType = 1, object_name = "10058", vIndex = 4)

results

if you try it in your local Rstudio, it should work and the result would be like this:
`10058` 10058$total_inflow
[,1]
2020-06-22 11:09:00 0
2020-06-22 11:24:00 0
2020-06-22 11:39:00 0
2020-06-22 11:54:00 0
2020-06-22 12:09:00 0
2020-06-22 12:24:00 0
2020-06-22 12:39:00 0
2020-06-22 12:54:00 0

But when I use AWS (amazon web services) ec2 and run this model in its studio, I get the error (the figure above) that says "the previous R session was abnormally terminated due to an unexpected crash".

Is it enough for replicating my code?

I suspect you are running out of RAM memory in your EC2 instance, I have tried to reproduce on AWS but I get a different error

library(swmmr)

download.file("https://github.com/HamedGhodsi90/CSO_Real-Time_Prediction/blob/master/SWMM_online.out",
              "SWMM_online.out")

results <- read_out(file = "SWMM_online.out", iType = 1, object_name = "10058", vIndex = 4)
#> Warning in read_out(file = "SWMM_online.out", iType = 1, object_name =
#> "10058", : error reading out file

results
#> $error
#> [1] 1

Created on 2020-06-25 by the reprex package (v0.3.0)

Thank you for your reply. I believe the source file I uploaded was changed. I uploaded it again.
Can you run your model again to see if your Rstudio crash or not.
use this link plz:
https://github.com/HamedGhodsi90/CSO_Real-Time_Prediction/raw/master/SWMM_online.out

download.file("https://github.com/HamedGhodsi90/CSO_Real-Time_Prediction/raw/master/SWMM_online.out", "SWMM_online.out")
results <- swmmr::read_out(file = "SWMM_online.out", iType = 1, object_name = "10058", vIndex = 4)

Please let me know what is your output.

However, if we assume you do not get crash:

  • how can I check the RAM memory in my EC2 instance? how can I clear it or do something to make it works?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.