deepstream is it possible to publish from my server, without opening a client connection in a browser - deepstream.io

I am somewhat confused in deepstream, is it possible to communicate to a client from my server? For example, is there any way to do something like this on a server? I am currently opening a client connection in browser that publishes to other clients. I would rather have the code below in my server.
var client = deepstream('localhost:6020').login()
var record = client.record.getRecord('new-record')
#Publish a message to all listeners of 'listen-channel' from my server?
record.set('listen-channel', 'message');
and then have clients listen:
record.subscribe('listen-channel', function(value) {
console.log(value);

Sure, just run it from a node process. Deepstream "clients" can be backend and frontend processes alike, permissioning is used to distuinguish between who can do what.

Related

Use websockets to update data from worker servers?

I have a server running expressjs that hosts the admin website and 4 to 10 additional worker servers that run a job scheduler and are constantly processing jobs and receiving new data. Is there a good way for the worker servers to notify the website server and then update the data on the website using websockets?
Worker servers can use any number of means for communicating with your main server. For example, you main server could have a special web server in your main server (not exposed to the outside world) that just receives http requests with data from the workers. So, whenever a worker gets new data, it just sends an http request to the main server.
Or, either webSocket or socket.io can be used server-to-server just fine (one end serves as the client for establishing the connection) and the other is the webSocket/socket.io server listening for incoming connections. In your case, the workers would be the clients and they would connection to your main server and then they can send data whenever they want over the webSocket or socket.io connection.
If you then want to automatically update data in various web browsers that have one of your pages open, those pages would also have a webSocket or socket.io connection open to your server so when your server gets new data, it could then tell the web page about it and the webpage could update its display without constantly refreshing/reloading a new page.
Either ws or socket.io can be used. Socket.io offers a number of features built on top of webSocket. You would choose socket.io if you want those added features. You can see a partial list of the added socket.io features here:
Moving from socket.io to raw websockets?

OpenShift v3 connect app with redis. Connection Refused

I have created a redis 3.2 application from the default image catalog.
I'm trying to connect a python app that runs inside the same project with the redis db.
This is what the Python application uses to connect to redis:
REDIS_HOST = 'localhost'
REDIS_PORT = 6379
REDIS_PASSWORD = os.environ.get('REDIS_PASSWORD') or 'test'
redis = aioredis.create_redis_pool(
(REDIS_HOST, int(REDIS_PORT)),
password=REDIS_PASSWORD,
minsize=5,
maxsize=10,
loop=loop,
)
The deployment fails with an ConnectionRefusedError: [Errno 111] Connection refused.
My guess is that I need to use another value for REDIS_HOST, but I couldn't figure what to use.
Does anyone know how to fix this?
After you deployed from the image catalog a number of objects will have been created for you. One of those objects is a service, which is used to load balance requests to the Pods it fronts. Service names for a project can be retrieved using the client tools via oc get svc.
This service name should be used to connect to your redis instance. If you deploy redis before your Python application, some environment variables should already be populated which can be used, for example REDIS_SERVICE_HOST and REDIS_SERVICE_PORT.
So from your application you can connect via the service ip or service name, where service name is redis then redis.StrictRedis(host='redis', port=6379, password='secret')
The redis password may have been generated for you. In that case it is retrievable from the redis secret which could also be mounted from your python app
Databases in general do not use standard HTTP, but custom TCP protocols. This is why in Openshift we need to connect directly to the service using Openshift's Service hostname or IP address (caution: only Service hostname is predictable), instead of the usual Route, and this applies also to Redis. Bypassing the Routes in Openshift is like bypassing a reverse proxy such as nginx and directly connecting to the db backend.
There is need to use env variables, because service hostnames are auto-generated by Openshift using this predictable pattern:
container_name.project_name.svc , e.g:
redis.db.svc
More info
"When a web application is made visible outside of the OpenShift cluster a route is created. This enables a user to use a URL to access the web application from a web browser. A route is usually used for web applications which use the HTTP protocol. A route cannot be used to expose a database, as they would typically use their own distinct protocol, and routes would not be able to work with the database protocol."
[https://blog.openshift.com/openshift-connecting-database-using-port-forwarding/ ]

local stun server inside a closed LTE network

First of all, apologies if the title doesn't match the description.
We, in our organization are working on peer-peer video communication solution within a closedLTE network. For this purpose, we are using open source webrtc client peerjs along with their local peerjs server. The server by default refers to google stun server.
1. Is stun server required in case of closed LTE network?
2. If yes, can we make use of a open source stun server which could run locally instead of the default one?
3. If no, what are the changes I would need to do?
I have setup one open source stun server [https://github.com/enobufs/stun] but failed to carry out further connections with the clients.
I setup the server as per the instructions provided in the link. Now instead of the default stun server , I put the 'local-ip-address:port' and tried to make a connection between the peers. But it dint work.
var configuration = { "iceServers": [{ "urls": "local-ip-address:port" }] };
pc = new RTCPeerConnection(configuration);
Am i doing it the wrong way?
Please guide me through.
Thanks in advance
Coturn is very popular stun/turn server with active community support.
Pre-built packages available at https://github.com/coturn/coturn/wiki/Downloads
You can test the server with sample demo
If both the parties are in same network, then no need to configure turn stuff like credentials. Read more
Configuring the peerConnection:
STUN server: //server_ip is coturn instance ip should be reachable from clients
var iceServers= [{"url": "stun:server_ip:port"}];
or TURN server:
var iceServers= [{"url":["turn:server_ip:port"],"username":"turn_username","credential":"turn_password"}];
var pc_config = {"iceServers": iceServers};
var pc_constraints = {
"optional": [{"DtlsSrtpKeyAgreement": true}]
};
pc = new RTCPeerConnection(pc_config, pc_constraints);

Chat Application Suggestion .Net

I am going to develop a chat application, I am confused which way I choose. Below are the option, please suggest me which/why is the best way to create a chat application.
WCF Duplex chat
Socket
XMPP
Thanks
Anuj
if you are going for a client server style of chat then ive always found using sockets to be a simple way to do it. If you create the server and add the socket you want it to be listening at.
Create a client that will then connect to the server for this you will enter the ip of the server and the socket. The client then connects to the server and the server will add the client to the client list. When the client sends a message to the server the server will then use a loop the send the message to all the clients in the list.
You will need to make this multi threaded as the clients will always need to be listening for new messages being sent from the server while still allowing the user to send new messages to the server. Its not very complicated at all a quick google and you will find all the code you could ever need for it

Is it possible to retrieve a list of WebLogic Domains from Node Manager?

Given a connection to NodeManager is it possible to have it tell you what domains it has registered?
I'm thinking of writing an tool for internal use that would list information about the servers running in the domains (up, down, port, etc) and it would be nice to have the tool automatically include new domains as they are created.
I know I could just parse the nodemanager.domains file, but that means the app has to have access to the server's file system. I'd like to avoid that if possible.
Is JMX an option? If so, just read Accessing WebLogic Server MBeans with JMX.
Building a connection:
JMXServiceURL serviceURL =
new JMXServiceURL(protocol, hostname, port, jndiroot + mserver);
JMXConnector connector = JMXConnectorFactory.connect(serviceURL, options);
MBeanServerConnection connection = connector.getMBeanServerConnection();
Getting the domains:
String[] domains = connection.getDomains();
Monitoring changes is also possible.