Are there any websocket plugins for nodejs - sockets

Are there any websocket plugins for nodejs; I would like to develop some application that uses websockets.

Checkout Socket.IO - it's a widely used and powerful Node module for socket connections.

WebSocket-Node is a pure WebSocket implementation in node.js that supports the latest version of the WebSocket spec (version 8), and is still being actively maintained.
Otherwise Socket.io has broader browser support because it can fall back to things such as Flash Sockets, long lived iframes etc.

Like cmpolis mentioned, Socket.IO is excellent. Just upgraded to 0.8 too.
nowjs also provides a higher-level api if you like more abstraction.
Similar to nowjs, dnode allows you to call remote functions between the client and server and vice versa.
Here is a great SO answer delineating the differences between them.

Related

Web Socket: IIS WebSocket Protocol feature need to be enabled for Socket.io?

For one of my application, I have implemented Web socket using socket.io and hosted in IIS. Currently socket connection helping to provide two way connection between client (React) and server (node.js).
As I mentioned, I have hosted my application in IIS. I have few doubts regarding Turn Windows features on or off -> Internet Information services -> World wide Web Services -> Application Development Features -> WebSocket Protocol. I have tested my application without enabling this feature, its working fine, but I would like to confirm below stuffs.
WebSocket Protocol
Do I really need to enable WebSocket protocol feature to make websocket work in my application? If so, how now it is working fine without enabling (I haven't do performance and stress testing, I may face issue on this).
What if I not enabling this feature? in short what is the actual use of this feature?
It would be helpful if anyone answer the above questions. Thanks in advance.
WebSocket as part of the HTTP stack requires a bunch of things to be ready on Windows (across multiple components), so hope this answer helps a little.
HTTP.sys, a driver deep down in Windows OS, is upgraded to support the necessary packet communication required by the protocol.
The IIS WebSocket module, an IIS extension which many other Microsoft frameworks (like SignalR) depend on.
So WebSocket support is by default on in HTTP.sys, and you don't need the IIS module if your framework (socket.io) has no dependency there.
Note that the "Summary" section provides several useful links,
https://learn.microsoft.com/en-us/iis/get-started/whats-new-in-iis-8/iis-80-websocket-protocol-support#summary
and the same article also reveals that IIS WebSocket module has
conflicts with socket.io.

How to send HTTP 2.0 request in play framework(scala)

Backend running under play framework(v. 2.6.5 scala) must communicate with Apple Push Notificaton Service (APNs) . APNs requires using HTTP/2, and so i tried to find any way to implement such communication, but to my surprise i didn`t find any http scala clients, supporting http v 2.0.
Is there any way to realize such communication without going out of the framework?
Thanks!
Play Framework with a version prior to 2.6 does not support HTTP 2.0, but, Play Framework 2.6 is based on Akka-Http and has experimental support for HTTP 2.0. This feature is labeled "experimental" because the API may change in the future, and it has not been thoroughly tested in the wild.
To add support for HTTP/2, add the PlayAkkaHttp2Support plugin. You can do this in an enablePlugins:
lazy val root = (project in file("."))
.enablePlugins(PlayScala, PlayAkkaHttp2Support)
If you consider alternatives take a look at:
Jetty has a capability to use HTTP 2.0
Netty also supports HTTP 2.0
Check this list of known implementations of HTTP 2.0.
In Akka HTTP, which underlies Play! Framework, HTTP/2 support is experimental on the server side and not yet available on the client side, as far as I can tell. Work is in progress and is tracked on Github. Unless you're inclined to write HTTP/2 client support yourself and optionally donate it to the project (which would probably be a very satisfying experience), going outside of the framework is probably going to be a necessity for now, I'm afraid.
If you're in a position to use Java 9 (hey, it's been gold for two days!), you might consider its HTTP/2 client.
Vert.x is originally a Java framework inspired by NodeJS, but in its current incarnation it includes an HTTP/2 client with a Scala API: http://vertx.io/docs/vertx-web-client/scala/ - I've never used it in production so YMMV...
Edit: you might also consider sttp with the OkHttp backend, which supports HTTP/2.

Can I use sockets on Appengine without a special lib?

I'm confused by the GAE documentations. It says App Engine supports sockets without requiring you to import any special App Engine libraries or add any special App Engine code. but it seems misleading as just above it says App Engine supports outbound sockets through the appengine/socket package.
I would like to connect to an IMAP server using the standard net package. Is that possible or I'm stuck with the GAE sockets API?
https://cloud.google.com/appengine/docs/go/sockets/
It is not possible to open an outbound socket without going through the appengine/socket api. This is because it works through RPC and an appengine.Context is needed to do that. You can still use the IMAP library you linked, though, as it provides a function to create a client with a given net.Conn. You can get a net.Conn from appengine/socket and pass it to NewClient to do your business. The reason it works on python and java is because they both use thread local memory to manage request state implicitly, whereas the go runtime does not.
Nothing stops you from connecting to an Imap server, since you will initiate an outbound connection. For java, the standard java mail packages work out of the box.
Only for paid apps though, i.e. you need to have billing enabled.

Can I use socket.io with Play Framework 2.0 Web Sockets?

There's a sample application that comes with Play Framework 2.0. The application uses Play's WebSocket implementation on the server side. I am wondering can I use socket.io on the client side to connect with Play's WebSocket implementation on the server side?
In theory, yes, you can make Socket.io connect to your websocket server wia the corresponding ws url.
In practice, I tried and I had some issues, so it might require you to adapt Socket.io for it to work properly. Granted I tried on 2.0.1 or similar, so it may be working currently with no issues.

Communicating with Java web app from non-java app through TCP/IP socket

Hosting an application on a web application server e.g. JBoss automatically brings in lots of app server specific functionalities with it e.g. security, clustering & load balancing etc. I have a situation where I have to develop a server app with which, legacy apps can talk to over TCP/IP socket as well as be highly available. Initially, I had though of using JBoss app server to leverage its clustering support for HA. However, I am not sure whether it would be possible to connect to a JBoss web app using pure TCP/IP sockets from both java and non-java apps.
What is the best way to achieve this without using web service or Http approach?
UPDATE: I am specially interested to know how legacy apps will connect to the hosted web app through TCP/IP socket.
A really simple solution to bridge the two worlds would be to add a simple Java server which maps the old TCP/IP requests to HTTP requests. This is probably a pretty braindead task, so this "server" will be simple to write and maintain. Also, this server won't need as much power since it just accepts and forwards connections (no business logic or DB code).
On the JBoss server, you develop like you normally would. The legacy apps connect to the little bridge server which passes the requests on to JBoss and translate the result back.
This ensures that you're building for the future: When new apps are developed, they can connect directly to JBoss and use all the great HTTP features.
There's no reason why you can't open up a normal socket in (say) a servlet application hosted in JBoss.
You can then get a byte stream from this. The headache is then to decide on a platform-independent representation of your messages, such that your client end can format and send such that the JBoss-hosted end can read. But it's all perfectly feasible.
I would implement a very simple http (1.0) client.