@microservice-framework/microservice-websocket

1.2.4 • Public • Published

microservice-websocket

Gitter npm microservice-frame.work

Websocket service to provide API access and receive information about new data.

Configure NGINX to proxy WebSocket requests

upstream apiv1ws {
    server api1.server.com:6001;
    server api2.server.com:6001;
}

server {
    listen       443 ssl;
    server_name  my-server.com www.my-server.com;
    underscores_in_headers on;
    large_client_header_buffers 4 64k;
    ssl_certificate ssl/my-server.com.crt;
    ssl_certificate_key ssl/my-server.com.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;

    location /ws_endpoint/ {
      limit_conn                 conn_from_one_ip 20;
      proxy_pass                 http://apiv1ws/;
      proxy_http_version         1.1;
      proxy_send_timeout         15m;
      proxy_read_timeout         15m;
      proxy_set_header           Upgrade $http_upgrade;
      proxy_set_header           Connection "upgrade";
      proxy_set_header           Host       $host;
      proxy_set_header           X-Real-IP  $remote_addr;
      proxy_set_header           HTTP_X_FORWARDED_FOR  $remote_addr;
      proxy_set_header           X-Forwarded-For $proxy_add_x_forwarded_for;
    }

}
    

WebBrowser Javascript example:

    <script src="http://microservice-frame.work/js/microservice-client.min.js"></script>
    <script>
$(function() {    
    var clientSettings = {
      URL: "wss://my-server.com/ws_endpoint/",
      token: 'secureKey or AccessToken'
    }
    ws = new MicroserviceWebSocket(clientSettings);
    ws.on('message', function(object){
      console.log(object);
    });
});
    </script>

Readme

Keywords

none

Package Sidebar

Install

npm i @microservice-framework/microservice-websocket

Weekly Downloads

2

Version

1.2.4

License

GPL-3.0

Unpacked Size

26.5 kB

Total Files

13

Last publish

Collaborators

  • microservice-framework