Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for a fetch-like API for TCP (and UDP) sockets. #708

Open
jo-carter opened this issue Apr 25, 2024 · 2 comments
Open

Add support for a fetch-like API for TCP (and UDP) sockets. #708

jo-carter opened this issue Apr 25, 2024 · 2 comments

Comments

@jo-carter
Copy link
Contributor

In a similar fashion to OpenResty's ngx.socket.tcp

My use-case for this would be for interacting (populating) Memcached directly from NJS (in a non-hack way). Of course there would be many other use-cases - for various TCP/UDP services.

@zizifn
Copy link

zizifn commented Oct 5, 2024

Thanks for the feature. But do you know how to do TCP in current njs?

@jo-carter
Copy link
Contributor Author

jo-carter commented Oct 5, 2024

@zizifn It cannot be done properly with njs directly at present.

The hack way to do it with njs is to make a http fetch (or via a subrequest + proxy_pass) request to a local Stream Context Virtual Server that contains a js_filter script, and have that script then manipulate request into whatever the protocol should be (and likewise back-translate to response to http) - which sort of works for simple protocols - see memcached.

However, I wouldn't recommend using this approach if you have other options...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants