Giter VIP home page Giter VIP logo

elasticsearch-transport-websocket's Introduction

⚠️ This repository will be removed soon without any further notice

Elasticsearch WebSocket transport plugin

Follow @xbib on Twitter

NOTE: I plan to move this plugin over to a Ratpack-based plugin: https://github.com/jprante/elasticsearch-plugin-ratpack If you have questions, concerns, comments, feel free to open an issue.

This is an implementation of WebSockets for Elasticsearch.

WebSockets are implemented as an Elasticsearch transport plugin using the latest implementation of WebSockets in the Netty project.

The WebSocket protocol specification defines an API that enables web clients to use the WebSockets protocol for two-way communication with a remote host. It defines a full-duplex communication channel that operates through a single socket over the Web. WebSockets provide an enormous reduction in unnecessary network traffic and latency compared to the unscalable polling and long-polling solutions that were used to simulate a full-duplex connection by maintaining two connections. WebSocket-based applications place less burden on servers, allowing existing machines to support more concurrent connections.

Elasticsearch offers a HTTP REST API for nearly all the features available, so using it via curl or via script languages is comparable to a HTTP client connecting to a HTTP server. Some limitations apply when using the REST API and WebSockets come to the rescue.

Motivations for implementing an Elasticsearch WebSocket transport layer are

  • to supersede the HTTP request/response model by a full-duplex communication channel

  • to implement scalable and responsive real-time apps, like distributed publish/subscribe services

  • to attach thousands of clients to an Elasticsearch node without service degradation

  • to allow sequences of bulk index and delete operations on a single connection

  • to implement new types of streaming applications like subscribing to change streams from ElasticSearch indexes

Versions

Elasticsearch version Plugin Release date
1.4.0 1.4.0.0 Jan 8, 2015
1.3.1 1.3.1.0 Jul 30, 2014
1.2.1 1.2.1.1 Jun 9, 2014

Installation

./bin/plugin -install websocket -url http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-transport-websocket/1.4.0.0/elasticsearch-transport-websocket-1.4.0.0-plugin.zip

Do not forget to restart the node after installing.

Project docs

The Maven project site is available at Github

Issues

All feedback is welcome! If you find issues, please post them at Github

Overview

Modules

The transport plugin uses Netty WebSockets for server and clients. WebSocket clients can connect to an Elasticsearch Node with the transport plugin installed. Between nodes, WebSockets connections may establish when needed for forwarding messages. The more nodes are installed with websocket transport, the more clients can get connected.

WebSocket Module

Websocket

The WebSocket module includes a module that allows to expose the Elasticsearch API over HTTP. It is superseding the standard HTTP module on port 9200-9299.

The http mechanism is completely asynchronous in nature, meaning that there is no blocking thread waiting for a response. The benefit of using asynchronous communication for HTTP is solving the C10k problem.

When possible, consider using HTTP keep alive
when connecting for better performance and try to get your favorite client not to do HTTP chunking.

Setting Description
websocket.port A bind port range. Defaults to 9400-9499.
websocket.max_content_length The max content of an HTTP request. Defaults to 100mb
websocket.compression Support for compression when possible (with Accept-Encoding). Defaults to false.
websocket.compression_level Defines the compression level to use. Defaults to 6.

Node level network settings allows to set common settings that will be shared among all network based modules (unless explicitly overridden in each module).

The network.bind_host setting allows to control the host different network components will bind on. By default, the bind host will be anyLocalAddress (typically 0.0.0.0 or ::0).

The network.publish_host setting allows to control the host the node will publish itself within the cluster so other nodes will be able to connect to it. Of course, this can't be the anyLocalAddress, and by default, it will be the first non loopback address (if possible), or the local address.

The network.host setting is a simple setting to automatically set both network.bind_host and network.publish_host to the same host value.

Both settings allows to be configured with either explicit host address or host name. The settings also accept logical setting values explained in the following table:

Logical Host Setting Value Description
local Will be resolved to the local ip address.
non_loopback The first non loopback address.
non_loopback:ipv4 The first non loopback IPv4 address.
non_loopback:ipv6 The first non loopback IPv6 address.
[networkInterface] Resolves to the ip address of the provided network interface. For example en0.
[networkInterface]:ipv4 Resolves to the ipv4 address of the provided network interface. For example en0:ipv4.
[networkInterface]:ipv6 Resolves to the ipv6 address of the provided network interface. For example en0:ipv6.

TCP Settings

Setting Description
network.tcp.no_delay Enable or disable tcp no delay setting. Defaults to true.
network.tcp.keep_alive Enable or disable tcp keep alive. By default not explicitly set.
network.tcp.reuse_address Should an address be reused or not. Defaults to true on none windows machines.
network.tcp.send_buffer_size The size of the tcp send buffer size (in size setting format). By default not explicitly set.
network.tcp.receive_buffer_size The size of the tcp receive buffer size (in size setting format). By default not explicitly set.

Disable WebSocket

The websocket module can be completely disabled and not started by setting websocket.enabled to false.

License

Elasticsearch Websocket Transport Plugin

Copyright (C) 2012 Jörg Prante

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations

elasticsearch-transport-websocket's People

Contributors

jprante avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elasticsearch-transport-websocket's Issues

ES 1.4 Fails On Start After websocket plugin install

I realize ES 1.4 is not officially supported but just a heads up, when I installed 1.3.1.0 to a 1.4 server, the startup fails with this message:

[2014-11-14 06:01:28,771][INFO ][org.xbib.elasticsearch.http.netty.NettyWebSocketServerTransport] [Wild Child] detected host name by reverse IP lookup: tpmint
{1.4.0}: Initialization Failed ...

  1. NoSuchMethodError[org.elasticsearch.action.support.nodes.TransportNodesOperationAction.(Lorg/elasticsearch/common/settings/Settings;Ljava/lang/String;Lorg/elasticsearch/cluster/ClusterName;Lorg/elasticsearch/threadpool/ThreadPool;Lorg/elasticsearch/cluster/ClusterService;Lorg/elasticsearch/transport/TransportService;)V]2) NoSuchMethodError[org.elasticsearch.rest.BaseRestHandler.(Lorg/elasticsearch/common/settings/Settings;Lorg/elasticsearch/client/Client;)V]

Compatibility with version 0.90.x

I tried to build the project with maven and i tried to install it as a plugin via "plugin -install jprante/elasticsearch-transport-websocket/1.0.0", but both failed. Is there any chance you can make it compatible with current versions?

use with node.js websocket?

I am trying to simply connect right now, but it is not working due to ES returning status code 200 instead of 101. It very easily could be that I am using the wrong URL, port, etc. I am not even sure how to debug this, so any pointers would be helpful.

Install

npm install websocket

Code

var WebSocketClient = require('websocket').client;

var ws = new WebSocketClient();
ws.connect('ws://localhost:9400/_stats');
ws.on('connect', function(connection) {
    console.log('connected!');
});
ws.on('connectFailed', function(err) {
    console.log('ERROR: ' + err);
});

Output

ERROR: Server responded with a non-101 status: 200
Response Headers Follow:
content-type: application/json; charset=UTF-8
content-length: 97

PubSub

Hi,

How to use the WebSocket plugin to be notified of changes in an index ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.