Brief Summary
The typical workflow is the following:- Client makes a websocket connection to the server.
- Client immediately receives a WelcomeResponse JSON message from the server notifying the client what its session ID is.
- Client can send JSON requests over the Web Socket connection.
- Client can receive JSON responses over the Web Socket connection. These messages are received asynchronous from its requests and may not even be tied to a specific request.
- Client can keep the connection open as long as it wants, and can disconnect when it wants.
Make the Connection
Clients first need to make a WebSocket connection to the Hawkular Server. That is done by connecting to the URL: "ws://Note that a secure connection via SSL can be made by connecting to “wss://
Receiving the Welcome Message
For each client websocket connection that is made, the server sends an initial WelcomeResponse message immediately to it. This message contains the client’s session ID. This is the session ID that the server will use to identify that client. This session ID is actually not needed by the client today, but it is available for future functionality. For now, clients can actually ignore this session ID.An example WelcomeResponse message that a client could receive is:
WelcomeResponse={“sessionId”:”abc:123:xyz:789”}
The WelcomeResponse JSON schema is defined here.
Sending a Request Message
Once connected, clients can immediately begin sending any valid request over the web socket connection. Because clients are able to send in different kinds of requests, the client must ensure the request message’s JSON content is prefixed with the JSON schema name followed by “=” . Valid JSON schemas can be found here.Within the JSON content, there must be an authentication node containing the credentials of the client. The authentication node’s JSON schema is defined here.
So, for example, if you want to execute the “Undeploy” operation on a web deployment resource, the request sent over the web socket connection will look something like this:
ExecuteOperationRequest={“authentication”:{“username”:”joe”,”password”:”pw”},“operationName”:”Undeploy”,”resourcePath”:”/t;tenant-id/e;env-id/r;resource-id-of-the-deployment-resource”}
Note that in order for a client to request something related to a specific resource in inventory, that client must know the resource’s “resource path” as defined in Hawkular Inventory. See the Hawkular Inventory REST API documentation for more details on how to obtain inventory data such as these resource paths.
Receiving a Response Message
The clients can receive messages in the same format as it sent them. In other words, the JSON content received by the client will be prefixed with the JSON schema name that is to be used to properly parse the JSON content received.For example, when a client sends a request message destined to an agent, the server will immediately send a GenericSuccessResponse back to the client. This means the request was received by the server and has been successfully forward to the agent (note: it does not mean the request was successfully processed by the agent - the agent will send its own success or failure response message back once it processes the original request). Such a response message received by the client would look like this:
GenericSuccessResponse={“message”:”The request has been forwarded to the feed [foo]”}