Skip to content

ntkog/arcgis-websockets-streamserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ArcGIS WebSocket Server

This node server behaves as a GeoEvent StreamServer layer, so it will emit geographic features in the Esri JSON format though a WebSocket. This way we will be able to display a real time layer in ArcGIS without an ArcGIS Enterprise stack.

custom websocket server in arcgis

It can be used with any ArcGIS developer technology or any other product. For example add the StreamServer to a webmap and visualize it in Operations Dashboard, ArcGIS Pro, any Storymap, etc.

Start the app

We are assuming you are familiar with NodeJS, if you are not please read this first

  1. Check init.js and fill in SERVICE_CONF object properly.
const SERVICE_CONF = {
  name : "twitter",
  out_sr : {
    wkid : 102100,
    latestWkid : 3857
  },
  port : 9000,
  host : process.env["NGROK"]  || "localhost",
  protocol : process.env["NGROK"] ? "https" : "http"
};

Be aware of the name : "twitter". It will be propagated below, in the instructions. If you want to use othe name, change it also along the instructions.

  1. Start the real time server: node init.js "ws://localhost:8888" "4.11"

In this example ws://localhost:8888 is the websocket connection we want to consume data from. This websocket connection it's not the same as the one which will be exposed by StreamServer. But don't worry, all will be wired up (luckily)

It will check the websocket connection first. If it's any problem, it will notice it, and it will warn you :-)

If it's able to connect, it "automagically" set the fields for your StreamServer according to the payload received in the websocket connection attempted before.

  1. Start a web server: cd example & http-server -p 9090
  2. Open: http://localhost:9090/
  3. Stream service url: http://localhost:9000/arcgis/rest/services/twitter/StreamServer

Using HTTPS (NGROK)

If you want to test this from the sandbox sample you can also use ngrok

  1. Run: ngrok http 9000
  2. Stop init.js and run NGROK=yourid.ngrok.io node init.js "ws://localhost:8888" "4.11"
  3. Use: https://yourid.ngrok.io/arcgis/rest/services/twitter/StreamServer instead of http://localhost:9000/arcgis/rest/services/twitter/StreamServer

Known issues

ArcGIS API for JavaScript version <= v4.8 & v3.x

UPDATE : Working in a version which can handle any version! Cross your fingers!

Before this commit on May 5, 2015 this streamserver was only working with JS API <= v4.8 and v3.x. If you want to know more you can also check this issue.

Documentation

About

Auto-Magic Arcgis Streamserver from websocket source

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published