Can one say an architecture using websocket technology is based on client-server model? - websocket

Can one say an architecture using websocket technology is based on client-server model?
By definition The client–server model is a distributed application structure that partitions tasks or workloads between the providers of a resource or service, called servers, and service requesters, called clients.
However using the websocket technology, two endpoints can both act as providers of a resource or service and also service requesters.
Say for example in a situation where the two endpoints are: a user device with a gps sensor and a computer machine, both connected in the network using websocket. And the computer machine is sending requests to obtain the current position of the user device (here the user device is acting as a resource provider and the computer machine as a requester). Later on the user device uses the websocket connection to request all its positions on the last 5 days to the computer machine (now the user device is acting as the requester and the computer machine as the resource provider).
If both devices can act as resource provider and requester, are they complying with the client-server model definition or not?

No it's not breaking anything. End Points are not devices they are connections between devices.
ie if we were asking each other questions and answering them
There would two connections between two 'devices' giving four endpoints. You to me and me to you. No conflict.

TCP is full duplex capable, and particularly WebSockets are full duplex. As #Tony Hopkinson pointed out, there is no conflict at all. This means, you can write and read at the same time.
WebSockets are push technology, more suited for events; while usual request-response models are pull technology.
You can have both client-server or peer to peer architectures with push approach, but pull is the normal choice for pull architectures.
Peer-to-peer Architecture: A peer-to-peer network is designed
around the notion of equal peer nodes simultaneously functioning as
both "clients" and "servers" to the other nodes on the network. This
model of network arrangement differs from the client–server model
where communication is usually to and from a central server. A typical
example of a file transfer that uses the client-server model is the
File Transfer Protocol (FTP) service in which the client and server
programs are distinct: the clients initiate the transfer, and the
servers satisfy these requests.
You can also provide a mix of peer-to-peer and client-server. For example, you can do requests via WebSocket, and at the same time, the server could send updates on its own initiative. I don't understand what you mean with "breaking the model". WebSocket is just a communication channel. In your app both models can coexists and use the same communication channel.

Related

How to Route Messages to Microservice Instances Dynamically Based on Key/Value?

I'm building a system where client IoT devices will be making persistent websocket connections to a single instance of a microservice. We'll call it the "hardware gateway". End devices will be connecting to one of these service instances and may migrate between services at anytime (perhaps due to a reboot or network interruption).
Other services will be pushing notifications to these hardware clients via some hardware gateway instance. I need a way to route these requests to the specific instance that is maintaining a connection to a specific IoT device. At the moment, my solution is to maintain an external KV store where I can map an IoT device's UUID to a service instance, but that puts an extra dependency on all other services to know about this KV store. Not to mention the additional latency introduced by this query.
Maybe there's some reverse proxy that allows me to dynamically update its matching criteria? I've also looked into using a message broker like RabbitMQ, but it doesn't seem to support this use case.
There's a reasonable solution in JVM land for this: Akka.
The instances form an Akka cluster. When a device makes a websocket connection, an actor is spawned to handle the interactions over the websocket. The actor registers that it is the actor interacting with the device with a cluster sharded actor keyed by the device's ID (and likely periodically reregisters with the sharded actor). As instances are deployed, etc. the cluster rebalances. An important feature of this is that the service is stateful, but the instances deploy in a way that looks to the outside world like it's stateless: requests can go to any node.
For pushing notifications to the devices, the HTTP endpoint or message-bus consumer in the service looks up the cluster sharded actor which forwards the notification to the websocket actor (you'll want to think about whether you want at-least-once or at-most-once delivery, which will govern whether there's some portion of the cluster sharded actor which should be persistent).

What exactly does a XMPP server do?

Besides federation (talking to other XMPP server), what's the role of an XMPP server in the communication between two peers?
Wikipedia says that
The XMPP network uses a client–server architecture; clients do not
talk directly to one another.
In that case, they must talk through the server, so messages must go through the server, correct?
Does it role change if we're using XMPP over Websockets, BOSH, or bare TCP?
For instance if we use XMPP over Websockets, is there a Websocket between client1 and the server, and another Websocket between client2 and the server?
An XMPP server provides basic messaging, presence, and XML routing features. This page lists Jabber/XMPP server software that you can use to run your own XMPP service, either over the Internet or on a local area network. Wikipedia is also right. According to wikipedia it means that it uses server client system. It is a system in which a computing system composed of two logical parts: a server, which provides information or services, and a client, which requests them. On a network, for example, users can access server resources from their personal computers using client software. Server client system is widely used for communication purpose and also in DBMS
actually it is a communication protocol for message oriented middle ware ( lies between software and application ) based on xml (extensible markup language ) It enables the near-real-time exchange of structured yet extensible data between any two or more network entities.

Does blockchain use websocket?

Im programming an application for sharding on a p2p network but p2p networks have some serious problems like forwarding port , static ips and these things get a lot of time for me and it can be so bad for marketing and users.
After all i wanna use smart contract on a blockchain to pay for it.
Does blockchain use websocket for transfer blocks and data and give miners blocks ?
No blockchain's nodes relay transactions and blocks to their neighbours node after that they participate in the validation process.
Ordinary users use wallets which connect to a node, this communication can base on socket or rest api

Integration of Shenzhen Concox Information Technology Tracker GT06 with EC2

I have a concox GT06 device from which I want to send tracking data to my AWS Server.
The coding protocol manual that comes with it only explains the data structure and protocol.
How does my server receive the GPS data collected by my tracker?
Verify if your server allows you to open sockets, which most low cost solutions do NOT allow for security reasons (i recommend using an Amazon EC2 virtual machine as your platform).
Choose a port on which your application will listen to incoming data, verify if it is open (if not open it) and code your application (i use C++) to listen to that port.
Compile and run your application on the server (and make sure that it stays alive).
Configure your tracker (usually by sending an sms to it) to send data to your server's IP and to the port which your application is listening to.
If you are, as i suspect you are, just beginning, consider that you will invest 2 to 3 weeks to develop this solution from scratch. You might also consider looking for a predeveloped tracking platform, which may or may not be acceptable in terms of data security.
You can find examples and tutorials online. I am usually very open with my coding and would gladly send a copy of the socket server, but, in this case, for security reasons, i cannot do so.
Instead of direct parsing of TCP or UDP packets you may use simplified solution putting in-between middleware backends specialized in data parsing e.g. flespi.
In such approach you may use HTTP REST API to fetch each new portion of data from trackers sent to you dedicated IP:port (called channel) or even send standardized commands with HTTP REST to connected devices.
At the same time it is possible to open MQTT connection using standard libraries and receive converted into JSON messages from devices as MQTT in real time, which is even better then REST due to almost zero latency.
If you are using python you may take a look at open-source flespi_receiver library. In this approach with 10 lines of code you may have on your EC2 whole parsed into JSON messages from Concox GT06.

Does websocket only broadcasts the data to all clients connected instead of sending to a particular client?

I am new to Websockets. While reading about websockets, I am not been able to find answers to some of my doubts. I would like if someone clarifies it.
Does websocket only broadcasts the data to all clients connected instead of sending to a particular client? Whatever example (mainly chat apps) I tried they sends data to all the clients. Is it possible to alter this?
How it works on clients located on NAT (behind router).
Since client server connection will always remain open, how will it affect server performance for large number of connections?
Since I want all my clients to get real time updates, it is required to connect all my clients to server, so how should I handele the client connection limit?
NOTE:- My client is not a Web browser but a desktop application.
No, websocket is not only for broadcasting. You send messages to specific clients, when you broadcast you just send the same message to all connected clients, but you can send different messages to different clients, for example a game session.
The clients connect to the server and initialise the connections, so NAT is not a problem.
It's good to use a scalable server, e.g. an event driven server (e.g. Node.js) that doesn't use a seperate thread for each connection, or an erlang server with lightweight processes (a good choice for a game server).
This should not be a problem if you use a good server OS (e.g. Linux), but may be a limitation if your server uses a desktop version of Windows (e.g. may be limited to 200 connections).

Resources