Select to view content in your preferred language

Stream Layer with Web Socket Authentication

147
1
04-09-2025 07:09 AM
AndrewMurdoch1
Frequent Contributor

Good Day

I have a Stream Layer that works, is there a way to add a Bearer token in the header of the Web Socket when the Stream Layer connects, if so, how?

Here is my current Stream Layer object:

        const websocket = 'ws://blah'

        return new StreamLayer({
            fields: metaLayer ? this._metaFields : fields,
            geometryType: geometry,
            id: streamLayerId,
            labelingInfo: [layerLabelClass],
            maxReconnectionAttempts: 100,
            maxReconnectionInterval: 10,
            objectIdField: 'objectId',
            renderer: renderSetting,
            timeInfo: {
                trackIdField: "assetSectionId"
            },
            webSocketUrl: `${websocket}`,
            updateInterval: 100
        })



Thanks

0 Kudos
1 Reply
UndralBatsukh
Esri Regular Contributor

Hi there, 

You should be able to use StreamLayer.customParameters to add additional params like token.

0 Kudos