Communicate between web server and raspberry pi - java

Assume that I have web server (ad-box.deslab.vn) and raspberry pi is a client connected to my web server. (Server and Client is not in local network)
Beside using socket, How can I send a string from web server to raspberry pi?
What languages can I use to code for web server and client?

You can use MQTT (MQ Telemetry Transport or Message Queue Telemetry Transport) which is an ISO standard publish-subscribe-based lightweight messaging protocol for use on top of the TCP/IP protocol. It is designed for connections with remote locations where a "small code footprint" is required or the network bandwidth is limited.
Below you can find the list of some MQTT clients in various languages.
http://www.hivemq.com/blog/seven-best-mqtt-client-tools
https://www.ibm.com/support/knowledgecenter/SS9D84_1.0.0/com.ibm.mm.tc.doc/tc10100_.htm

Related

Netty's local transport for communication within a JVM

I am reading chapter 4.3.4. Local transport for communication within a JVM of the Netty in Action book. There I find:
Netty provides a local transport for asynchronous communication
between clients and servers running in the same JVM.
However, no example is given. Does anyone have more knowledge about this topic and can give an example?
What I am interested in is implementing a reverse proxy using Netty.
In this case we would have a web server receiving requests and using that local transport to forward them to a client, that finally sends them to other host. Then receiving back response from the client and using again the local transport to return the response to the web server which sends it to the user. So the JVM that runs Netty would be just a reverse proxy between the web clients and local machines.

TCP to HTTP communication

I have an IOT device which is sending data continuously to a configured server using TCP protocol.
Can i receive the data using HTTP protocol and any java http services application like spring-boot application?
Device details : https://teltonika.lt/product/fmb920/
As the device was returning the data in TCP protocol so I could not get any solution to get data in http protocol.
I achieved that by establishing the TCP connection using sockets.

how to secure Socket communication so that only authorised client application can connect or listen to the port of server application

I have server application which runs on local host and the client also runs on local host.
As of now I am using java.net.serversocket and any application which has the ip and port detail of server can listen to the port.
My requirement is to secure the ports or secure the communication between the server and client application such that only my application client (authorised) one can listen to the ports or connect to server application. The data sent to and from client and server also has to be secured.
Apologies if naming conventions are not correct. I have been searching for solution and couldn't get anything for this, all I got is how to connect and make application communicate using socket programming , but no where I got the answer as how to secure the communication.
What you need here is some sort of authentication method to authorise only your client to communicate with the server. If you are using an existing communication protocol then it might have a specification for authentication already. If you are using your own protocol then you'll have come up with your own design for authentication.
It could be as simple as the server issuing some sort of request for authentication to the client. The client would then have to provide a satisfactory response (eg a user/password) otherwise the server would close the connection.
I would recommend taking a look at how some other protocols (eg HTTP) handle authentication to get some insight and also understand potential pitfalls.

Connecting two separate sockets through serversocket

I'm developing a chat application in Java that enables client to connect to a predefined port and when two clients are connected the server should connect those two sockets and data should be exchanged between them.
I know to create a ServerSocket and Socket that will connect and establish a communication between them through a separate port and a server socket. But, how can I connect those two connected clients?
If you are creating a chat application then Chat server will not connect client socket in order to communicate.
You can try following approach:
On server side Use a HashTable to store connected clients.
When you receive a message from client, include a an id of CLient to whom message is to be sent and simply pass on the message to other client.
There will be separate threads running for these clients, so you need to have a policy to control the load on server.
This questions sounds like a homework assignment.
If you would like to see a great contemporary demo of a chat system you may learn from Play's WebSocket chat sample application.

Consume WCF from Java client hosted on Linux server

Can WCF service hosted as TCP IP or Named Pipes on windows server be consumed by Java based application hosted on linux server?
I have a wcf service which requires low latency and very high calls per day. Hosting the service on IIS is not an option due to performance issues and HTTP overhead. This service needs to be consumed by java based client hosted on linux server. Can it be consumed by Java client if it is hosted on TCP end-point? Looks like Named Pipes are only allowed within the same machines so it wont fit the requirements too.
Only binding that assures "interoperability" in WCF is BasicHttpBinding.
If you need minimum overload don't use WCF.
Write your own tcp based protocol, use sockets or whatever you like.
Here is answer to very similiar question.

Categories