sciviews / svsocket Goto Github PK
View Code? Open in Web Editor NEWSciViews R socket server
Home Page: https://www.sciviews.org/svSocket
License: Other
SciViews R socket server
Home Page: https://www.sciviews.org/svSocket
License: Other
I'm trying to write a custom server. The input and output are large JSON objects, so I thought the best solution was to write a custom procfun so I didn't need to worry about escaping quotes.
Here is my test code:
library(svSocket)
processTestSocket <-
function (msg, socket, serverport, ...)
{
cat("Message was:",msg,"\n")
output <- paste0("message:",msg)
return(output)
}
options(debug.Socket=TRUE)
startSocketServer(port=12525,server.name="EAServer",
procfun=processTestSocket)
This returns TRUE
in the console.
However, when I try to test the port using telnet, it closes immediately.
$ telnet localhost 12525
Trying ::1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
$ sudo ss -l |fgrep 12525
tcp LISTEN 0 4096 0.0.0.0:12525 0.0.0.0:*
tcp LISTEN 0 4096 [::]:12525 [::]:*
$
What am I missing?
Hello, it needs a working version of Tcl/Tk (>= 8.4), but SystemRequirements
field is missing in DESCRIPTION
.
This issue seems to be specific to running the svSocket server as as a "job" within Rstudio. Running the server via Rscript (CLI) or another instance of Rstudio works fine.
I receive the following error when I attempt to grab an object from the socket server (running as a "job" within Rstudio):
> evalServer(con2, stream_tbl)
[1] "Error in eval(parse(text = \"stream_tbl\")) : object 'stream_tbl' not found\n"
attr(,"class")
[1] "try-error"
attr(,"condition")
<simpleError in eval(parse(text = "stream_tbl")): object 'stream_tbl' not found>
I incorporated some ls() checks into my server script, and the stream_tbl object is definitely present in the environment. As mentioned above, everything works fine if I execute the server script using Rscript (CLI) or open up another instance of Rstudio and execute the script. Is there a obvious solution to this? I can post an MWE if needed.
Peter
Hi,
I am writing to inform you that a possible bug has been detected in the svSocket (1.0.2) package in the R-devel version (4.2.0). I tested it on three machines: 1) my local Windows 10 machine; 2) virtual machine with Windows Server 2019 on AWS; 3) virtual machine with Windows 10 professional on Azure platform.
The error message is:
Error in assign("last.warning", last.warning, envir = baseenv()) :
cannot add binding of 'last.warning' to the base environment
About two years ago a similar error message was detected in Microsoft R Open and the problem was solved with the instruction that can be seen (see attached figure:
) in line 33 of the info.R file which is open in Tinn-R . However, it is not working for R-devel.
Workaround bug: MRO and svSocket
unlockBinding("last.warning",
baseenv())
Is it possible to know if the bug is in R or in the svSocket package? How to fix?
Problem Version 1, Can we make pr_fun process it's retun without waiting for ch_fun() to finish
ch_fun <- function() {Sys.sleep(10)}
pr_fun <- function() {ch_fun(); return("Done")}
pr_fun()
Proble Actual Version
R session 1 as svSocket Server
library(svSocket)
startSocketServer(port = 9875,local=FALSE)
R session 2 as svSocket client
con <- socketConnection(port = 9875,host="127.0.0.1")
evalServer(con,"Sys.sleep(20)")
R session 3 as svSocket client
con <- socketConnection(port = 9875,host="127.0.0.1")
evalServer(con,"a=10")
If we run the code lines for session 2 and while server is processing Sys.sleep call we quickly put the code lines for session 3 in session 3 and abort the call it still gets processed. We can check that on server side by checking if object "a" was created.
My point is we didn't have to wait for job to finish in session 3 still it was processed so somehow jobs were piled up on session side and we don't have to wait for jobs to finish just send them to server and abort the waiting process and move ahead. We can manually abort using Ctrl+C or Esc but how can I do that in a function. I want pr_fun to call ch_fun in server session and proceed to its return immediately.
In vscDebugger/websocket (more specifically here) I am trying to use this package to handle requests sent by a debug client and send back responses via a tcp socket.
As far as I understand, the functions from this package handle messages only line by line. Unfortunately, the messages specified in the Debug Adapter Protocol are not terminated with line breaks, so this approach did not work out of the box.
I tried to modify svSocket here to also read incomplete messages and it seems to work, but I don't know enough about tcl to know if these changes are a good way to achieve this.
Is reading/writing incomplete lines a feature you would consider implementing?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.