It is indeed possible to configure and test WebSockets in the Mews Demo environment.
Testing with credentials
The simplest way to test WebSocket connections would be to use a browser extension. For example, the Browser WebSocket Client Chrome extension.
Just as you will need a pair of Access and Client tokens to make various API calls to Mews, you will need the same to authenticate a WebSocket connection. The Client token corresponds to that of the generic "Are you ready to integrate with Mews?" integration in Mews Demo.
For the purposes of testing, you do NOT need to add a new integration. Instead, please use the pair of tokens listed in the Authentication section of our Mews Open API documentation.
Follow the URL format prescribed in the Endpoint part of the WebSockets documentation to set up the connection.
Maintaining the connection
Mews recommends that the integration sends a WebSocket Ping request to Mews at regular intervals (e.g., every five minutes) to monitor the connection. If the Ping request fails, the integration interface should be restarted or try to re-establish a connection.
Types of event you can test
Depending on what the integration does, you may wish to test any of the four types of WebSocket events listed in the API Documentation.
Simply make any changes to the relevant items in Mews (e.g., reservation, space, rate price, etc.) in order to trigger an event.
What it looks like in the production environment
When your integration has been successfully certified with Mews Marketplace, you will receive one unique Client Token for your integration, for the production environment. This should be paired with the Access Token (which differs from property to property).
For each property that adds an integration to their Marketplace subscriptions, a new Access Token will be generated, and it is unique to the specific property. You can then use the pair of Access/Client tokens to establish a WebSocket connection between the property's Mews environment and your integration interface.
Testing without credentials
If you are mainly interested in the type and content of the WebSocket notification that will be generated by a particular event in Mews, you can test WebSockets without needing to configure a connection.
- Go to dashboard and open the devs tools for Chrome (F12), click on "Network" and then select "WS". Reload the page if needed and you will see the WebSocket in the list:
- Click on it and select the tab "Messages". From there you will be able to see all the WebSocket events:
- When you make an action that triggers an event, you will see it listed there as
"Type":"Events", and you can click on it to see the details for it (in this example you can see how the resource was changed to "Inspected"):
If you are able to connect to the WebSocket but do not see any events coming in, simply make any action in the Mews demo hotel you are connected to, to trigger an event. E.g., create a reservation, check in a reservation, make a space as Inspected, etc.