-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Version Information
CLI Version: Currently using v2.19.0
What is the current behaviour?
Subscriptions does not work in the API Explorer when running the console locally connected to an external Hasura instance that only support HTTPS/WSS. Query and mutations works without problems (uses HTTPS). But, the subscriptions does not work because they are trying to use WS instead of WSS.
What is the expected behaviour?
Subscriptions works in the API Explorer when running the console locally connected to an external Hasura instance that does not support HTTP/WS.
How to reproduce the issue?
- Create the configuration files to connect to an external Hasura instance:
hasura init --endpoint "https://your-hasura-domain" - Launch the Hasura console:
hasura console - Create and track tables to use for subscriptions
- Go to the API Explorer tab and create some valid subscription
- Open the Network tab of the browser developer tools
- Filter the url by the websocket scheme:
ws - Run the subscription
- Wait until you see some request in the network tab using
wsinstead ofwss
Screenshots or Screencast
The next image show in the left panel that I'm using HTTPS, but in the right side in the network tab it's trying to connect using WS instead of WSS. (The image was edited just to remove the hasura instance domain).
Any possible solutions/workarounds you're aware of?
I searched the codebase and found a commit that probably introduced this "unexpected" behavior. In the code section below the url used to make the connection for the subscription executes the getWebsocketProtocol function using the window.location.protocol.
| const websocketProtocol = getWebsocketProtocol(window.location.protocol); |
But when running the console locally connected to an external Hasura instance window.location points to http://localhost, with the HTTP protocol (that after is transformed to WS). And instead, it should use the GraphQL Endpoint of the external instance that uses HTTPS.
Keywords
WSS, WS, websocket, subscription