StreamConnection

AMD: require(["esri/layers/support/StreamConnection"], (StreamConnection) => { /* code goes here */ });
ESM: import StreamConnection from "@arcgis/core/layers/support/StreamConnection.js";
Object: esri/layers/support/StreamConnection
Since: ArcGIS Maps SDK for JavaScript 4.25

A web socket connection to a stream service. The connection to the stream service can be established by calling StreamLayer's connect() method.

See also
Example
// get layer's connection configurations
const parameters = layer.createConnectionParameters();

// set the spatial reference of the service geometries
parameters.spatialReference = new SpatialReference({
  wkid: 2154
});

const connection = await layer.connect(parameters);

// listen to date-received event once the connection is established
// create a graphic from the JSON object returned and add them to view
connection.on("data-received", (feature) => {
  const graphic = Graphic.fromJSON(feature);
  graphic.symbol = myPointSymbol;
  view.graphics.push(graphic);
});

// close the connection when it is not needed anymore
connection.destroy();

Property Overview

Name Type Summary Object

The error that explains an unsuccessful attempt to connect to the stream service or an unexpected disconnection from the stream service.

StreamConnection

The status of the Web Socket connection with the stream service.

StreamConnection

Property Details

connectionError

Property
connectionError Error |null |undefinedreadonly

The error that explains an unsuccessful attempt to connect to the stream service or an unexpected disconnection from the stream service.

connectionStatus

Property
connectionStatus Stringreadonly

The status of the Web Socket connection with the stream service. This property can be watched to see if the connection is lost unexpectedly.

Possible Values:"connected" |"disconnected"

Method Overview

Name Return Type Summary Object

Destroys the existing connection instance to the stream service.

StreamConnection

Method Details

destroy

Method
destroy()

Destroys the existing connection instance to the stream service.

Event Overview

Name Type Summary Object
{attributes: Object,geometry: Object}

Fires when the stream connection receives data.

StreamConnection

Event Details

data-received

Event
data-received

Fires when the stream connection receives data. The event object contains the message properties received from the stream service.

Properties
attributes Object

Name-value pairs of fields and field values associated with the received data.

geometry Object

A location of the received data containing x, y coordinates for points, paths for lines and rings for polygons, and the spatial reference wkid.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close