websocketd | uses STDIN/STDOUT into a WebSocket server | Websocket library
kandi X-RAY | websocketd Summary
kandi X-RAY | websocketd Summary
websocketd is a small command-line tool that will wrap an existing command-line interface program, and allow it to be accessed via a WebSocket. WebSocket-capable applications can now be built very easily. As long as you can write an executable program that reads STDIN and writes to STDOUT, you can build a WebSocket server. Do it in Python, Ruby, Perl, Bash, .NET, C, Go, PHP, Java, Clojure, Scala, Groovy, Expect, Awk, VBScript, Haskell, Lua, R, whatever! No networking libraries necessary.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of websocketd
websocketd Key Features
websocketd Examples and Code Snippets
Community Discussions
Trending Discussions on websocketd
QUESTION
Is it possible to send a socket.io message to my localhost server (node) using the command line in linux?
My socket.io code looks like this:
...ANSWER
Answered 2017-Feb-07 at 23:43I was able to work around this by doing the following:
Create a new endpoint in your server
QUESTION
I was looking at using websocketd as a web sockets server, but I don't see how it can be used to respond to the full set of websocket events such as onerror and onclose.
...ANSWER
Answered 2017-Jan-15 at 18:51What you're asking for is not how it works. You don't program websocketd and it doesn't have any events. You use as a stand-alone tool to wrap some other program and then each incoming connection starts an instance of the program you've configured it to wrap. Then, any incoming messages are send to stdin of that program and any stdout response from the program is sent back to the client that connected to the websocket server. You can think of it like a tool that just forwards incoming websockets messages to stdin of your app and captures the output and forwards that back to the client.
As you presumably know, the idea is that without doing any server programming yourself, you could create a remote interface to any command line tool on your computer (with the associated caveats/risks that has) that expects to get its input from stdin and writes its output to stdout. That remote interface could be in a web page or could be any other program you write that uses a webSocket to communicate with the websocketd server you configured and ran on your host. So you only write the client-side of things. The websocketd doc does not say what it does with output that it finds on stderr.
When a web socket client connects to this websocket server, an instance of your program will get started up. So, in essence, the onconnect
event is that your program started. When the client disconnects, it will kill your program (that's essentially the onclose
event).
It is not clear what it does if it gets webSocket errors in sending data back to the client. You'd have to dissect the code here https://github.com/joewalnes/websocketd to try to figure that out (it appears to be written in go
. Presumably, since it's a server itself and there's no interface, probably the most that happens is that the error is logged or maybe the webSocket is disconnected. Without modifying the code, there's no provision for you to participate in what happens when there's a webSocket communication error. The daemon has a preprogrammed behavior.
I do see examples here in the code where it deals with errors from reading stdout
and it logs those errors and then closes the stdout stream.
The code here appears to close the incoming webSocket if it gets errors while reading from it.
QUESTION
Before asking my specific question my overall objective (in case there is a better way to do it) is to log data from a particulate matter sensor (PMS) with GPS co-ordinates on my ride to/from work to see how bad the air on my commute is.
So far I have the PMS connected to a raspberry pi, and am recording values from it using a python script.
I'm recording all these logged values to to a log.txt
file following the process outlined here: https://www.perrygeo.com/raspberry-pi-real-time-sensor-plots-with-websocketd.html
I've then set-up a websocket (using websocketd
) from the pi, which I can access from my computer. This just spits out a current time-stamp, and the particulate matter reading I'm interested in (again following tutorial linked above).
My question is how to access the data from this websocket in an Android App - ideally using MIT App Inventor 2 (as I'm a newb in Android). My google-fu has failed me on this one.
I'm also happy to be told that a websocket is not the best way to do it - I could serve up a JSON file on a webpage instead and parse that from the android app if that'd be easier, but had thought a websocket would be better/faster.
Having done a bit more research there is an extended discussion on this here: https://groups.google.com/forum/#!topic/ai4a/pL4bHmJKnH0 It's suggested that I might be able to use a socket rather than a web-socket - I'd also be happy to do that.
...ANSWER
Answered 2019-Oct-16 at 20:37Ok, it seems to do anything beyond the basics in MIT App Inventor 2 you need to add "extensions" which is what I was missing from my google search terms.
Specifically the following extension did exactly what I was needing - hope it's of help to other people who stumble upon this question (including me in the future!):
https://community.appybuilder.com/t/websocket-client-extension/1761
Finally I noticed that using the websocketURI
with the host-name of the server machine (in my case raspberrypi
did NOT work - I had to use the IP address. If anyone know why that might be and how to make the host-name discoverable on android please let me know!
QUESTION
A user uploads a python file that I need to execute on my server and send back the stdout that's created over a WebSocket. The python file that's executed will run for several minutes and I need to return the stdout over a socket as they are "printed" out in real-time, not at the completion of the script.
I've tried using: Python. Redirect stdout to a socket, but that's not a WebSocket and my React frontend can't connect to it successfully. (if you can solve that, that would also solve my problem)
I've also tried using websocketd
but since I can't add sys.stdout.flush()
after each of the users' added print statements it doesn't solve my problem.
I've also tried using subprocess's PIPE functionality but that has the same flush issue
...ANSWER
Answered 2019-Aug-19 at 05:07This stand-alone example will
- Read a
python
script from a web socket - Write the script to the file system
- Run the script with output buffering disabled
- Read the script output one line at a time
- Write each line of output to the web socket
QUESTION
I am trying to test out Websocketd and hence want to transmit a image in binary
My server-side used with websocketd:
...ANSWER
Answered 2019-Aug-15 at 15:47A simpler solution would be to put this in your server script:
QUESTION
I'm using WebSocketd to send data and retrieve it form STDOUT, then using JS to access the message:
...ANSWER
Answered 2018-Jul-23 at 21:34As far as I am aware, setting the value of an input programmatically will not focus
it, nor will it trigger a keyup
event to trigger. You can, however, trigger the focus
event or keyup
event manually after the WebSocket sends a message. This may be what you're looking for;
QUESTION
I'm writing tests for my full-duplex server, and when I do multiple (sequential) async_write
calls (although covered with a strand), I get the following assertion error from boost::beast
in the file boost/beast/websocket/detail/stream_base.hpp
:
ANSWER
Answered 2018-Jun-06 at 23:39You said you cover your async_write
with a strand. But you do no such thing. All you can be seen doing is wrapping the completion handlers in that strand. But you're posting the async operations directly.
What's worse, you're doing it from the main thread, while there are async operations underway on any of the threads associated with your WSClient
instances which means you're concurrently accessing object instances that aren't thread-safe.
That's a data race, so you get Undefined Behaviour.
A naive fix might be:
QUESTION
I'm trying to host a simple (demo) websocketd server. Basically, it listens to incoming websocket connections and routes them towards my server. However, when I run the websocketd --port=8069 server.bash
(In the correct directory, websocketd running as admin) I get the following error when trying to connect to ws://localhost:8069
:
ANSWER
Answered 2017-Jun-10 at 09:40Description of websocketd from the url you provided
It takes care of handling the WebSocket connections, launching your programs to handle the WebSockets, ....
So basically websocketd is trying to execute server.bash
which doesn't work because windows doesn't recognize this file as executable.
This script was probably meant to be run on linux in the first place however if you have installed bash already on windows u can try running it by replacing
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install websocketd
To get started, we’ll create a WebSocket endpoint that will accept connections, then send back messages, counting to 10 with 1 second pause between each one, before disconnecting.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page