Websocket Manager with Playframework and Scala - scala

I want to use web sockets because I need to notify my users when there is a new message for them. And I’ve done a lot of research and I’m pretty sure I need to use WebSockets for this problem.
I was able to connect to my backend with the following steps: https://www. playframework.com/documentation/2.2.x/ScalaWebSockets
This allows my frontend to connect to my backend and has received the answer from the backend.
But how is it possible to manage all currently active web socket connections? Is there a method that I can use to find all active connections? Or do I have to implement all this from scratch?

Related

Can Vapor 4 serve both HTTP and HTTPS requests in the same application?

I have a Vapor 4 app which is successfully serving HTTPS requests with no issues.
I would like it to also respond to HTTP requests on a custom port number, which will be for providing some back-end control and monitoring hooks that are called by other services on the same server, and won't be publicly reachable.
When I search Google and browse the Vapor docs for how to do this, I only get results for a very old version of Vapor, using a configuration file to specify HTTP/HTTPS server and port configurations.
Does anyone know if this type of configuration be done on Vapor 4?
Cheers and thanks in advance!
No Vapor 4 cannot serve different protocols on the same port/application. The easiest way around is to run two instances of the application, one for each. Or just get the internal traffic to use HTTPS.
Another option would be to stick Nginx in front or similar

Suggestion or help needed for implementing stateless ejabberd architecture

I want to implement a real-time chat application. Technologies, database and OS used for this purpose:
Node.JS
Ejabberd as XMPP server
MySQL Database
React-Native (Front-End)
OS - Ubuntu 18.04
By far, I have achieved setting up ejabberd and registering the user and getting status from both the API and command line. For example, I can register a user from any other device/system and from the command line too. But the problem with this is that all the data gets stored in ejabberd database on the Ubuntu server due to which there are data duplication chances also I already have a database structured and defined and already have data in that.
In ejabberd tutorials, there is a part where they have mentioned stateless architecture where the ejabberd server manages XMPP part with our database (I didn't understand a lot about this stateless thing). So I need some help, example or tutorials where there is more understanding about the stateless architecture.
Already gone through below mentioned links -
https://blog.process-one.net/wp-content/uploads/2016/09/designing-a-modern-XMPP-service-with-ejabberd.pdf
https://www.youtube.com/watch?v=-dqQfCpw98E&feature=youtu.be&t=1m33s (Tutorial where Stateless is mentioned)
https://www.slideshare.net/mremond/xmpp-academy-2
https://docs.ejabberd.im/tutorials/ (Official tutorials about ejabberd)
Not-helpful links -
ejabberd stateless configuration
To configure stateless ejabberd, you need to configure your storage module to store the data using ReST API. Stateless ejabberd was designed for fluux.io service, but you can also implement it yourself using contributions or ejabberd API.
For example, for user based, you can rely on ejabberd_auth_http: https://github.com/processone/ejabberd-contrib/tree/master/ejabberd_auth_http

How should I build a server for mobile-apps

I'm planning to build an application that will include users registration and so on.. I want to build a kind of social network application and i wonder how should I build my server and what is the right way to connect between the application and the server?
I know to build clients and servers in python and connect between them with sockets, but I realise that this is not the right way to do it in mobile applications..
someone told me I should learn something called SOA or web application server , I did not understand him so well,
I hope that you understand what I search for, thanks!
A good start is to create a REST-based backend service that exposes methods/operations via HTTP. Host the service on your server, and allow the app to communicate with the service. This service can send and receive data, typically in the JSON format, between the service and your app(s). Try looking here for some examples:
Python: https://www.sitepoint.com/building-simple-rest-api-mobile-applications/
.NET: https://learn.microsoft.com/en-us/aspnet/web-api/overview/older-versions/build-restful-apis-with-aspnet-web-api

XMPP over BOSH - jappix.com replies always with empty body

I am implementing XMPP service in the browser using BOSH. I use JAXL library. I am able to manage the connection over BOSH to my localhost server (ejabberd). The session is started and the user is authenticated with no problem. However, when I just change the BOSH host to jappix.com, the very first response from the server is only empty body. Even if I repeat the request (according to XEP-206) I still get only empty body so I'm unable to perform any other actions.
So that's my question: Is it possible to use jappix.com to handle my BOSH requests? Are there any limitations? How can I fix this issue? I'll provide more information if needed.
I am the Jappix.com owner!
Your question does not concern our service directly but more likely a node-xmpp-bosh - the BOSH server we are running - bug (?) that you can report on http://code.google.com/p/node-xmpp-bosh/

Node.js and wss://

I'm looking to start using javascript on the server, most likely with node.js, as well as use websockets to communicate with clients. However, there doesn't seem to be a lot of information about encrypted websocket communication using TLS and the wss:// handler. In fact the only server that I've seen explicitly support wss:// is Kaazing.
This TODO is the only reference I've been able to find in the various node implementations. Am I missing something or are the websocket js servers not ready for encrypted communication yet?
Another option could be using something like lighttpd or apache to proxy to a node listener, has anyone had success there?
TLS/SSL support works for this websocket implementation in Node.js, I just tested it: https://github.com/Worlize/WebSocket-Node/issues/29
Well you have stream.setSecure() and server.setSecure().
I'm guessing you should be able to use one of those (specially the last one) to use TLS in websockets since in the end a websocket is just a normal http connection "upgraded" to websocket.
Using TLS in the normal http server object should theorically also secure the websocket, only by testing this can be confirmed.