Morning LEAF Team,
Do 3.9 generated data services still have LEAF websocket endpoints by default? I have a LEAF 3.9 React-app connecting to 3.9 data service. The environment.js/values.yaml both have a similiar configuration, pointing to a “socketPath” like so,
RelationshipDs: {
restPath: '/relationship-ds/rest',
socketPath: '/relationship-ds/socket/event-query',
}
I am unable to connect to the ws endpoint:
WebSocket connection to ‘ws://localhost/relationship-ds/socket/event-query’ failed:
and as a first step in debugging I figured I should check and see if a websocket endpoint is present by default in LEAF 3.9 data services.
thank you.
Morning, Steve. LEAF Data Service Generators do not enable a LEAF WebSocket endpoint by default. However, it is easier than ever in 3.7+ to enable it. (Up until 3.7, Data Services needed to have a WebSocket endpoint added manually.)
You have a couple of options:
- Set up the generated Data Service with a WebSocket endpoint to register DataChangeEventQueries with. To do so, merely enable the WebServer’s WebSocket connection. This was a single line change in my testing.
- Generate a DataChangeSubscription Service that is designed to expose DataChangeEvents via WebSocket connection. Check out the Data Change Subscription Service Generator to learn a bit more.
There are strengths and weaknesses to both approaches. Having a separate service exposing the WebSocket connection for DCEs allows you to scale the Data Service and DataChangeSubscription Service separately, but the cost is that you must maintain parity between Authorization Policies used in both services. See the LKB section about Synchronizing Authorization Policies for more info.
4 Likes
That was crazy easy, thank you Hayden.
Hey Hayden, is there a guide on LEAF for enabling a websocket connection for Data Services under LEAF version 3.7?
Thanks!
Hello, Tim.
The documentation for enabling a WebServer’s WebSocket connection can be found in 3.7 here. The required changes should be nearly identical to those of 3.9, I believe. Feel free to let us know if you run into trouble with those instructions.
Thanks Hayden, what about for a LEAF 3.5 service?
My apologies, Tim. I misunderstood your original question. Let me investigate and get back to you in a subsequent post.
Alright, there is documentation in the 3.5 LKB covering the addition of a WebSocket endpoint to a 3.5 generated Data Service, but it is under a page discussing how to set up a Data Service to work with the Metadata Editor Tool. You can find those instructions here.
Admittedly, they are a bit more involved. You should also be able to generate a 3.5 DataChangeSubscription Service and see the set up it uses. Largely, the set up in the LKB guidance and a generated DCSS should be similar.
1 Like