NancyFX / Linux / Mono - 大型上传(超过1MB)可以在Windows服务器上运行,但不能在Linux上运行(NancyFX/Linux/Mono - Large uploads (over 1MB) work on windows server but not linux)
我似乎有一个相当奇怪的问题,我想知道是否有人可以阐明。
我正在编写一个Android应用程序,它从自托管的C#服务器上传/下载文件。 服务器是用C#编写的(使用NancyFX自主机),Android应用程序使用HttpClient(Apache)与服务器通信。
当我尝试上传Windows上的文件(我手动调试到服务器代码的位置)时,上传适用于任意长度的任意数量的文件。 一切都按预期工作,小文件和大文件都上传。
但是,当我将此服务器部署到我的Linux机箱(OpenSuSe)并运行它时,上传的行为会有所不同。 较小的文件(<1MB)仍然按预期工作,但当文件超过此限制时,HttpClient的.execute()将无限期挂起。 我试图将套接字超时设置为10秒(测试),我曾经收到套接字超时异常,但有时,它只是挂在那里,甚至没有超时。 还值得一提的是,请求永远不会到达服务器 ,这可能意味着问题很可能不是南希服务器(虽然我可能是错的)。
鉴于问题的性质,我倾向于认为问题出在Linux服务器配置的某个地方,不管出于什么原因都不允许更大的POST请求,但我无法弄清楚为什么会出现这种情况。 我在同一个Linux机器上有一台PHP服务器,我可以上传大于1MB的文件,没有任何问题。
我尝试过的其他步骤:我已经在Linux服务器上禁用了防火墙以查看它是否是防火墙问题(因为<1MB很少到达服务器就不太可能),但这没有用。 我还将MTU改为与我的Windows机器一致,但这也没有什么区别。
就目前而言,我没有想法。 有谁知道如何进一步追踪这个以解决问题的根源? 任何帮助将不胜感激。
提前谢谢了。
I seem to have a rather strange problem which I was wondering if anyone could shed a light on.
I am writing an Android app which uploads/downloads files from a self hosted C# server. The server is written in C# (using NancyFX self-host) and the Android app is using HttpClient (Apache) to talk to the server.
When I attempt to upload the files on windows (which is where I manually debug into the server code), the upload works fine for any number of files with any arbitrary length. Everything works as expected and both small and large files get uploaded.
However, when I deploy this server to my Linux box (OpenSuSe) and run it, the uploads behave differently. The smaller files (< 1MB) still work as expected but when the file goes over this limit, the HttpClient's .execute() hangs indefinitely. I tried to set the socket timeout to 10 seconds (to test) and I once received a socket timeout exception but other times, it simply hung there, never even timing out. It's also worth mentioning that the request never reaches the server which would implicate that the problem is most probably not with the Nancy server (although I could be wrong).
Given the nature of the problem, I'm inclined to believe that the problem lies somewhere in the Linux server configuration which does not allow larger POST requests for whatever reason but I've not been able to figure out why that would be the case. I do have a PHP server on that very same Linux box and on that, I can upload files larger than 1MB without any problems.
Other steps I've tried: I've disabled the firewall on the Linux server to see if it was a firewall problem (highly unlikely since <1MB reaches the server just fine) but that didn't help. I also changed the MTU to be in-line with my windows machine but that did not make a difference either.
As it stands, I'm out of ideas. Does anyone know how to trace this further to get to the bottom of the problem? Any help would be greatly appreciated.
Many thanks in advance.
原文:
最满意答案
我已经改变了一下你的代码并且运行良好:
1.您在代码中忘记创建
id="gender"
的小部件2.
reactiveValues(df=NULL)
3.数据表输出代码:
output$nText<- renderDataTable({ datatable(values$df, options = list(orderClasses = TRUE,lengthMenu = c(5, 10, 30), pageLength = 5))})
这是完整的应用程序代码:
library(shiny) library(shinydashboard) library(DT) ui <- dashboardPage( dashboardHeader(), dashboardSidebar(disable = TRUE), dashboardBody( tabItem(tabName = "signup", fluidRow( box(textInput("name", "이름"), textInput("gender", "이름"), selectInput("college", "대학", choices = list("간호대학", "경영대학", "공과대학", "농업생명과학대학", "미술대학", "법과대학", "사범대학", "사회과학대학", "수의과대학", "생활과학대학", "약학대학", "음악대학", "인문대학", "의과대학", "자연과학대학", "기타"), selected = 1), selectInput("team", "교내 소속축구팀", choices = list("싸커21", "아르마다", "에코플러스", "아크로", "P.O.S", "공대", "자연대", "관악사", "농대축구부 휘모리", "지오싸카스", "새츠", "샥스", "FC SEES", "Cells United", "프리템포", "남풍", "없음")), textInput("score", "점수"), actionButton("click_counter","Submit")), box(DT::dataTableOutput("nText")) ) ))) server <- shinyServer(function(input, output, session) { values<- reactiveValues(df = NULL) #values$df<- data.frame() observeEvent(input$click_counter, { name<- input$name gender<- input$gender college<- input$college team<- input$team score<- as.numeric(input$score) rank<- 0 new_row<- data.frame(rank,name,college,gender,team,score) values$df<- rbind(values$df, new_row) values$df<- values$df[order(values$df$score,decreasing=TRUE),] #print(values$df) values$df$rank<- 1:nrow(values$df) }) output$nText<- renderDataTable({ datatable(values$df, options = list(orderClasses = TRUE,lengthMenu = c(5, 10, 30), pageLength = 5))}) }) shinyApp(ui = ui, server = server)
I have changed a bit Your code and it is working well:
1. You forgot in Your code to create a widget with
id="gender"
2.
reactiveValues(df=NULL)
3. datatable output code :
output$nText<- renderDataTable({ datatable(values$df, options = list(orderClasses = TRUE,lengthMenu = c(5, 10, 30), pageLength = 5))})
Here is the full App code:
library(shiny) library(shinydashboard) library(DT) ui <- dashboardPage( dashboardHeader(), dashboardSidebar(disable = TRUE), dashboardBody( tabItem(tabName = "signup", fluidRow( box(textInput("name", "이름"), textInput("gender", "이름"), selectInput("college", "대학", choices = list("간호대학", "경영대학", "공과대학", "농업생명과학대학", "미술대학", "법과대학", "사범대학", "사회과학대학", "수의과대학", "생활과학대학", "약학대학", "음악대학", "인문대학", "의과대학", "자연과학대학", "기타"), selected = 1), selectInput("team", "교내 소속축구팀", choices = list("싸커21", "아르마다", "에코플러스", "아크로", "P.O.S", "공대", "자연대", "관악사", "농대축구부 휘모리", "지오싸카스", "새츠", "샥스", "FC SEES", "Cells United", "프리템포", "남풍", "없음")), textInput("score", "점수"), actionButton("click_counter","Submit")), box(DT::dataTableOutput("nText")) ) ))) server <- shinyServer(function(input, output, session) { values<- reactiveValues(df = NULL) #values$df<- data.frame() observeEvent(input$click_counter, { name<- input$name gender<- input$gender college<- input$college team<- input$team score<- as.numeric(input$score) rank<- 0 new_row<- data.frame(rank,name,college,gender,team,score) values$df<- rbind(values$df, new_row) values$df<- values$df[order(values$df$score,decreasing=TRUE),] #print(values$df) values$df$rank<- 1:nrow(values$df) }) output$nText<- renderDataTable({ datatable(values$df, options = list(orderClasses = TRUE,lengthMenu = c(5, 10, 30), pageLength = 5))}) }) shinyApp(ui = ui, server = server)
相关问答
更多-
你应该在UI边栏添加style =“position:fixed; overflow:visible”。 library(ggplot2) ## for mpg dataset library(shinydashboard) ## ui ui <- dashboardPage( dashboardHeader(title="MPG Data"), dashboardSidebar( sidebarMenu(style = "position: fixed; overflow: visi ...
-
我认为你没有提供使用户输入部分工作所需的数据,所以我已经评论过了。 我想你只需要 将雷达绘图代码放在shinyServer部分的renderPlot中 将plotOutput添加到ui部分 这对我有用: library(shiny) library(shinydashboard) library(fmsb) ui <- shinyUI(dashboardPage( dashboardHeader(title = "Working on it"), dashboardSidebar(), das ...
-
您需要使用observeEvent而不是eventReactive 。 你的代码看起来像这样: library(shiny) library(shinyBS) library(dplyr) library(shinydashboard) # javascript code to collapse box jscode <- " shinyjs.collapse = function(boxid) { $('#' + boxid).closest('.box').find('[data-widget=co ...
-
Ran update.packages()和更新的版本没有这个问题。 Ran update.packages() and newer versions didn't have this issue.
-
首先,在subset调用中,您可以跳过test$ (不是问题的原因): subset(test, MARKET==var) 我怀疑你的问题是var不是一个字符串,它是reactive的输出。 尝试使用var()而不是var来获取值 subset(test, MARKET==var()) First, in the subset call you can skip out test$ (not the cause of your problem): subset(test, MARKET==var) I ...
-
R Shiny:反应性错误(R Shiny: Reactive Error)[2022-02-04]
你的错误是这样的: base.monthly.payment <- (int() * price() * (1 - per.down()) * ((1 + int())^n())) / (((1 + int())^n()) - 1) base.monthly.payment使用int() , n() , per.down()和price() ,它们都是被动的。 因此base.monthly.payment也会被动反应。 因此,当您创建它/赋值时,您需要将它包装在一个reactive如下所示: bas ... -
shinydashboard框背景(shinydashboard box background)[2023-05-31]
您正在使用fluidPage和仪表板元素。 这种组合不起作用。 你必须调整UI才能完全成为这样的dashboardPage: { library('shiny') library('shinydashboard') } # UI ui<-dashboardPage( dashboardHeader( title="Sample Code" ), dashboardSidebar(), dashboardBody( column(6, h1(" ... -
仔细检查教程,我认为你需要在ui替换 box(plotOutput("plot1"), width=6, height=500) 通过 box(plotlyOutput("plot1"), width=6, height=500) 而在server只需更换 output$plot1 <- renderPlot({ ...... 通过 output$plot1 <- renderPlotly({ .... Check again the tutorial carefully, I think ...
-
事实证明,我没有正确引用值框; 我需要使用.small-box类: dashboardPage( dashboardHeader(), dashboardSidebar(), dashboardBody( tags$head(tags$style(HTML(".small-box {height: 50px}"))), valueBoxOutput(outputId = "vb") ) ) It turns out I wasn't ref ...
-
我已经改变了一下你的代码并且运行良好: 1.您在代码中忘记创建id="gender"的小部件 2. reactiveValues(df=NULL) 3.数据表输出代码: output$nText<- renderDataTable({ datatable(values$df, options = list(orderClasses = TRUE,lengthMenu = c(5, 10, 30), pageLength = 5))}) 这是完整的应用程序代码: library(shiny) library( ...