Promises/A+ logo

Hprose for Node.js

Join the chat at npm download optionalDependency Status npm version License


Hprose is a High Performance Remote Object Service Engine.

It is a modern, lightweight, cross-language, cross-platform, object-oriented, high performance, remote dynamic communication middleware. It is not only easy to use, but powerful. You just need a little time to learn, then you can use it to easily construct cross language cross platform distributed application system.

Hprose supports many programming languages, for example:

  • AAuto Quicker
  • ActionScript
  • ASP
  • C++
  • Dart
  • Delphi/Free Pascal
  • dotNET(C#, Visual Basic…)
  • Golang
  • Java
  • JavaScript
  • Node.js
  • Objective-C
  • Perl
  • PHP
  • Python
  • Ruby

Through Hprose, You can conveniently and efficiently intercommunicate between those programming languages.

This project is the implementation of Hprose for Node.js.

Hprose 2.0 for Node.js Documents(中文版):


Http Server

Synchronous Functions or Methods

Hprose for Node.js is very easy to use. You can create a hprose server like this:

var hprose = require("hprose");
function hello(name) {
    return "Hello " + name + "!";
var server = hprose.Server.create("");

To start it use:

node --harmony server.js

–harmony is a v8 options, hprose use it to optimize serialization. This is not required option, but it is recommended to use it.

Asynchronous Functions or Methods

In fact most nodejs service methods are asynchronous, you can publish asynchronous function like this:

var hprose = require("hprose");
function hello(name, callback) {
    setTimeout(function() {
        callback("Hello " + name + "!");
    }, 10);
var server = hprose.Server.create("");

Http Client

Then you can create a hprose client to invoke it like this:

var hprose = require("hprose");
var client = hprose.Client.create("");
var proxy = client.useService();
proxy.hello("world", function(result) {

To start it use:

node --harmony client.js


node --harmony-proxies client.js

Without –harmony-proxies, you need create proxy like this:

var hprose = require("hprose");
var client = hprose.Client.create("");
var proxy = client.useService(["hello"]);
proxy.hello("world", function(result) {

Or create client like this:

var hprose = require("hprose");
var client = hprose.Client.create("", ["hello"]);
client.hello("world", function(result) {

Exception Handling

If an error occurred on the server, or your service function/method throw an exception, it will be sent to the client. You need to pass an error callback function after succuss callback function to receive it. If you omit this callback function, the client will ignore the exception, like never happened.

For example:

proxy.hello("world", function(result) {
}, function(name, err) {

Tcp Server & Client

The Tcp Server & Client are used as same as the Http Server & Client.

To create a Tcp Server:

var server = hprose.Server.create("tcp://");

To create a Tcp Client:

var client = hprose.Client.create('tcp://');

Unix Socket Server & Client

The Unix Socket Server & Client are used as same as the Http Server & Client.

To create a Unix Socket Server:

var server = hprose.Server.create("unix:/tmp/my.sock");

To create a Unix Socket Client:

var client = hprose.Client.create('unix:/tmp/my.sock');

WebSocket Server & Client

The WebSocket Server & Client are used as same as the Http Server & Client.

To create a WebSocket Server:

var server = hprose.Server.create("ws://");

To create a WebSocket Client:

var client = hprose.Client.create('ws://');

Related Repositories



Hprose for Node.js ...



Go and NodeJS example ...

Top Contributors

andot gitter-badger


-   v2.0.40 zip tar
-   v2.0.39 zip tar
-   v2.0.38 zip tar
-   v2.0.37 zip tar
-   v2.0.36 zip tar
-   v2.0.35 zip tar
-   v2.0.34 zip tar
-   v2.0.33 zip tar
-   v2.0.32 zip tar
-   v2.0.31 zip tar
-   v2.0.30 zip tar
-   v2.0.29 zip tar
-   v2.0.28 zip tar
-   v2.0.27 zip tar
-   v2.0.26 zip tar
-   v2.0.25 zip tar
-   v2.0.24 zip tar
-   v2.0.23 zip tar
-   v2.0.22 zip tar
-   v2.0.21 zip tar
-   v2.0.20 zip tar
-   v2.0.19 zip tar
-   v2.0.17 zip tar
-   v2.0.16 zip tar
-   v2.0.14 zip tar
-   v2.0.13 zip tar
-   v2.0.12 zip tar
-   v2.0.11 zip tar
-   v2.0.10 zip tar
-   v2.0.9 zip tar