Select to view content in your preferred language

Stream Layer With Custom WebSocket URL + Azure WebPubSub + JS API 4.24

931
2
Jump to solution
11-02-2022 01:23 AM
Koob
by
Emerging Contributor

Hi,

I am trying to setup a StreamLayer with a custom WebSocket url, using Azure WebPubSub.

using the simple constructor as seen below:

 

const streamLayer = new StreamLayer({
    popupTemplate: {
      content: "OBJECTID={OBJECTID}, TRACKID={TRACKID}",
    },

    webSocketUrl: "wss://stream-layer.webpubsub.azure.com/client/hubs/SomeHub?access_token=xxx",

    objectIdField: "OBJECTID",

    fields: [
      {
        name: "OBJECTID",
        alias: "ObjectId",
        type: "oid",
      },
      {
        name: "TRACKID",
        alias: "TrackId",
        type: "oid",
      },
    ],

    timeInfo: {
      trackIdField: "TRACKID",
    },

    geometryType: "point",

    maxReconnectionAttempts: 100,
    maxReconnectionInterval: 10,

    renderer: {
      type: "simple",
      symbol: {
        type: "simple-marker",
        size: "8px",
        color: "gray",
      },
    },
  });

  map.add(streamLayer);

 

 

Azure WebPubSub requires an access token to be added as a query string to the end of the websocket url.

wss://stream-layer.webpubsub.azure.com/client/hubs/SomeHub?access_token=xxx

For some reason when trying use the websocket url on StreamLayer, it seems to remove the query string from the end of the websocket url?

So you end up with: wss://stream-layer.webpubsub.azure.com/client/hubs/SomeHub

0 Kudos
1 Solution

Accepted Solutions
Koob
by
Emerging Contributor

okay, found the answer:

needed to add custom parameters

customParameters: {
   access_token: "token"
}

 

View solution in original post

2 Replies
Koob
by
Emerging Contributor

okay, found the answer:

needed to add custom parameters

customParameters: {
   access_token: "token"
}

 

WalterSimonazzi_VicPol
Regular Contributor

Are you implementing your own websocket server because you are also finding that GeoEvent is not able to handle properly websockets using stream layers with real world rates of events per second? - like from 20-40 events per second) like in our case.

0 Kudos