Select to view content in your preferred language

Bug with Filter in StreamLayer with Custom WebSocket Url + ArcGIS JS API 4.25

663
2
11-11-2022 06:07 AM
Koob
by
Emerging Contributor

I've got a simple custom websocket server that adds a user to a specific websocket group during the handshake.

Using a constructor similar to the below:

 

 

new StreamLayer({
   webSocketUrl: "wss://somewebsocket",
   definitionExpression: "test=1",
   ...
});

 

 

even though my server is responding to the handshake with the correct filter, as seen below:

Koob_0-1668175376468.png

The stream layer is logging the below message:

[esri.layers.graphics.sources.connections.WebSocketConnection]

  1. {name: 'websocket-connection', details: undefined, message: "Tried to set filter, but server doesn't support it"}
    1. details: undefined
    2. message: "Tried to set filter, but server doesn't support it"
    3. name: "websocket-connection"
    4. [[Prototype]]: C

I debugged the minified WebSocketConnection class and found that the code is doing something like: config.filter === response.filter.

javascript does object comparison by ref, so simply checking if the response object does not equal config object will never succeed.

0 Kudos
2 Replies
mgeorge
Esri Contributor

Hi @Koob

We added the custom websocket input for StreamLayers really just for simple cases, with GeoEventSource for more fully featured services. Note that as part of mmgeorge/node-stream-service: Example for connection a custom WebSocket stream service to the 4.x Ar..., there's no logic for setting geometryDefinition or definitionExpression specified. We probably need to add to the known limits that this is unsupported for custom websockets (basically undefined behavior currently -- FYI, in some cases filter can actually be a string which is probably why you are seeing that code block not make any sense). 

What is your use case here? Are you planning on changing the definitionExpression / geometryDefinition at runtime, and your custom websocket server can handle this? 

0 Kudos
Koob
by
Emerging Contributor

hi @mgeorge, thanks for the response.

Currently I am using the `definitionExpression` to send the initial filter data to my websocket server to join specific groups.

for example: I have two tenants, tenant 1 and tenant 2.

tenant 1 should not see events for tenant 2.

within my StreamLayer definitionExpression I am setting some filter for example `tenant = tenant1` 

this gets sent down to my server during the initial handshake as part of the filter, which I then use to join a azure webpubsub group. which works as expected.

Just thought i'd point out the bug.