awslabs / awslabs/aws-mobile-appsync-sdk-android
Support for custom WebSockets subscription URL
- Dominant language
- Java
- Stars
- 106
- Forks
- 56
- PR merge metrics
- No merged PRs in 30d
Description
Issue described below is related to v3.0.1
The library does not allow configuring a separate URL for the WebSocket subscriptions endpoint. Instead it determines the WebSocket endpoint based on the ApiUrl provided in the configuration in WebSocketConnectionManager.getConnectionRequestUrl:
```
return new Uri.Builder()
.scheme("wss")
.authority(appSyncEndpoint.getHost()
.replace("appsync-api", "appsync-realtime-api"))
.appendPath(appSyncEndpoint.getPath())
.appendQueryParameter("header", Base64.encodeToString(rawHeader, Base64.DEFAULT))
.appendQueryParameter("payload", "e30=")
.build()
.toString();
```
This does not seem to be clearly documented and no proper error is reported when a custom domain name is used for ApiUrl (eg. https://our.custom.domain.com/graphql) when subscription is executed.
In our use case the AppSyncSubscriptionCall.Callback.onFailure is raised with "Expected HTTP 101 response but was '400 Bad Request'"
For us, using the "full URL" (eg. https://abcde123565defghj.appsync-api.eu-west-1.amazonaws.com/graphql) is not possible for all use cases.
The only workaround we have currently is to have separate instance of AppSync client for subscriptions, configured with the full URL and additional instances for all other GraphQL operations configured with URL with a custom domain name.
Please provide additional configuration property allowing configuration of the WebSocket endpoint for GraphQL subscriptions.
Contributor guide
Research direction
Start in WebSocketConnectionManager.getConnectionRequestUrl and trace how the ApiUrl is supplied through the AppSync client configuration. Define completion as allowing a separate WebSocket subscriptions URL while preserving the existing full-URL behavior and avoiding the reported 400 response for custom domains.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, graphql, java
- Domain
- api, mobile-dev, networking
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100