Communication Java to NodeJS? [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am exploring various ways that allow Java to connect and communicate with NodeJS. An example of what I am trying to achieve, is for example call Java methods from NodeJS, while allowing the Java method to manipulate Javascript objects. I know the JSObject class is helpful for this purpose. I have also heard so far of Dnode and ZeroMQ. Have you heard of or do you have experience in doing something similar? Would you suggest a way on how this communication Java to NodejS can be done?

I would go with an agnostic implementation.
A rest server on node js, maybe using restify listening for messages
A http client on the java side as httpclient to send messages to node.
this will also make it dead easy to test node implementation with curl and static requests; will enable you to implement authentication later on using any standard mechanism from oauth to basic and will let you change the client and the dispatcher independently later on
also you will be able to put any kind of standard load balancer in between, should you need the node app to scale.

Related

What is the best approach in java to call a C function running on another server? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
What is the best approach in java to call a C function running on another server? My application written in Java and running on an application server on server 'A' and I need to call a C function running on another server 'B' that doesn't have java installed.
Should we build a web service on server B to accept requests from my Web application on server A? or just call it remotely using RPC? and what is the performance of both?
First of all:
Just call it using RPC
There is no such thing as "just" when talking RPC. Unless you already have some CORBA or whatever solution in place, you will have to invest a serious amount of time to get this working.
Using a web service adds multiple layers of abstraction, which can affect latency. But of course, that is the more flexible solution.
I think it is fair (in 2018) to state: a reasonable architecture would provide some sort of (restful) HTTPS service on B. You should only look into other options if there are hard pressing reasons.

Java - What is the "industry standard" method to communicate between client and server in terms of using strings, etc [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
So usually, to have get and set methods in networking Java I use an enum, for example:
public enum MyEnum {
GET_NAME,
GET_ADDRESS;
}
etc. which the client application and server application would send between each other as a string and the appropriate task would be carried out.
I wanted to know how applications do this usually? What data do they send through the socket to make the program work, do they use ObjectStreams? Do they send bytes?
Wanted to know what the best practice would be to have a client-server setup for my own messaging application.
EXTRA INFO:
The client / server network I'm designing is for a PLUGIN in a GAME and therefore has to be instant / speedy ;)
All of that. Or something else.
The "industry" standard can be many things, depending on the domain you are looking at, or the decade when the solution was designed.
In 2018, most "new" client/server communication that gets defined doesn't operate on socket level. You rather define a set of restful APIs that the server offers, and data flows as JSON strings for example.
In other words: the official answer here is: there is no such as an industry-wide standard. To the contrary: what you are asking about (sending individual comments on socket level) is probably the exception, and not something that is common for real world architectures. People don't think in sockets and single commands. They think in terms of protocols, abstractions, maybe "remote procedure calls".

Will WebSocket achieve what I'm trying to do? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm creating a simple java application made in swing that communicates with a database. Multiple people will be using the application at the same time. As they are able to change things at the same time, if someone for example, adds a new user, and a different person is on that same page, I want the person who did not make the change to be notified that changes were made to the database since they last loaded it.
My lecturer in college advised me that WebSockets would be the way to go to achieve this, however after some reading about WebSockets in Java, it seems it is based to work with web browsers instead of between Java applications.
Can using WebSockets achieve what I am trying? Or, if not, what would be a way to achieve this?
Simple answer is Yes you can achieve what you needed
WebSocket is a communication protocol(#see RFC 6455) & it is not a must to use a Web browser.
You can achieve what you want to do with your app, it is just a matter of writing a custom WebSocket server to facilitate your requirements in your case sending database changes to the other clients(Which is called Server push)
There are several java libraries to get the work done,
netty WebSocket (My favorite)
jWebsocket
Atmosphere
Webbit
Netty WebSocket is a good one to start with and you can find examples in its project to write a custom client and a server

Best way of client server communication in Java [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am building an application where in the requirement is that, there is a main server, which will send signal to client server, based on this signal the client performs certain action and send back the response to the main server. Here there will be only one main server and can be multiple client servers. At a given time the main server can send multiple signal to multiple clients.
I am presently planning to do this using socket programming in Java using two ports. Do let me know the best way of achieving this? and also do we have any good existing API's that can be used?
Take a look at RMI: https://docs.oracle.com/javase/tutorial/rmi/ If you want something based on sockets/TCP/UDP/etc, writing something with Netty may be good solution -> http://netty.io/ (they have useful examples).
I would also recommend to consider plain Java Sockets if planned communication beetween server and clients is not comlex and you do not need all this stuff which is provided by libraries like Netty.

Is PHP server, and JAVA client possible? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have searched for some hours now, and can't find an answer. I have a homepage coded in php that needs to frequently send and receive data to a java program.
So far I have done it via POST, but I wonder if it's a better way to do it. I have tried with sockets. But only managed to find tutorials for php client connecting to a java server. But I need the reverse.
All modern languages allow you to send and receive data, no matter from which language is sent or received. Many large applications (such as Facebook API), work with simple methods such as POST, GET, PUT, DELETE, etc., that is a REST API, returning the data in a specific format (JSON, XML, RAW, etc.). This is innecessary if your application is a little piece of code, but you could take this idea and make something simple. So, there is nothing wrong if you are using the POST method, but just in case, I can name you other resources that you could take advantage of.
You can use WebClient.
Also, you can comunicate your PHP code with your Java code using sockets.
TCP sockets: for PHP read this, and this guide for Java.
WebSockets: Java WebSockets for Java and Ratchet for PHP.
Of course, you can use cURL too. For Java you can read this question and connect with php. If your application is very large and complex in the PHP side, I guggest you to use Laravel.

Categories